try with:
let charCodesString = JSON.stringify(charCodes);
and don't wrap getCharCodes(webString) in square brackets
function getCharCodes(s) {
let charCodeArr = [];
for (let i = 0; i < s.length; i++) {
let code = s.charCodeAt(i);
charCodeArr.push(code);
}
return charCodeArr;
}
let webString = window.AppInventor.getWebViewString();
let charCodes = getCharCodes(webString);
let charCodesString = JSON.stringify(charCodes);
window.AppInventor.setWebViewString(charCodesString);
works for me

