I was just wondering if you could read a JSON array using a variable. My code:
var runningtotal = 0;
var dollartoletter = {
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6,
"g": 7,
"h": 8,
"i": 9,
"j": 10,
"k": 11,
"l": 12,
"m": 13,
"n": 14,
"o": 15,
"p": 16,
"q": 17,
"r": 18,
"s": 19,
"t": 20,
"u": 21,
"v": 22,
"w": 23,
"x": 24,
"y": 25,
"z": 26
};
for (var i = 0; i < word.length; i++) {
var currentChar = word.charAt(i);
console.log(currentChar);
var numforcurrentChar = dollartoletter.currentChar;
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^this is what produces errors
console.log(numforcurrentChar);
var runningtotal = runningtotal + numforcurrentChar;
console.log(runningtotal);
}
If this is not possible, that's OK too. I would prefer not to use jQuery, but I'm fine with implementing it if it is required.