0

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 , 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"
},
user3871
  • 12,432
  • 33
  • 128
  • 268

1 Answers1

0

why not:

log(whatever.toLowerCase())

adrichman
  • 1,215
  • 10
  • 17
  • I was just using logs there to show the output. I am running other stuff in that if check that needs to know all matches of the key to the keys in object 2 – user3871 May 07 '14 at 13:07