This is a bit maddening. New to javascript and I haven't coded in ages. I am looking to convert a string of characters into their charCodes and dump them into an array. This is the current code:
function fillArray(str) {
var arr=[];
for (var i = 0; i < str.length; i++) {
arr.push(str.charCodeAt(str.charAt(i)));
}
return arr;
}
What ends up happening is if I sent it a string like "abcd", it will return [97,97,97,97]. Even though the charAt(i) should be iterating through, the array only seems to be formed by looking at the first character in the string only. What am I missing?