How can I use javascript String toLowerCase()
method against all keys in an object? I'm comparing the keys in Object 2 (wordBank) to the keys in Object 1 (taskObject) to see if there is a match... I call:
getAll(wordsObj["wordBank"]);
Which calls:
getAll : function (taskObject) {
for (obj in vocab) {
for (key in vocab[obj]) {
if (key in taskObject) {
log(taskObject);
log(key);
log(taskObject) outputs: Object {Nǐ: "You", hǎo: "good", wǒ: "I", shì: "am"}
log(key) outputs: wǒ hǎo shì
You can see here, that the log(key)
is not outputting Nǐ
, because the first letter is capitalized. How can I run toLowerCase()
against all keys in Object 2 so that it returns all matches regardless of case?
Object 1: All entries are lower case
var vocab =
{
"Subjects" :
{
'wǒ' : ['I/Me', path+sbj+'Wo_I.mp3'],
'nǐ' : ['You', path+sbj+'Ni_You.mp3'],
},
"Adjectives" :
{
'hǎo' : ['Good', path+adj+'Hao3_Good.mp3'],
'shì' : ['Am', path+adj+'Shi4_Am.mp3'],
Object 2 that I'm passing in to be compared:
"wordBank" : //need to grab words from word bank... this is not needed...
{
"Nǐ" : "You",
"hǎo" : "good",
"wǒ" : "I",
"shì" : "am"
},