lab_4

by Chris

JavaScript

var words = ["cat", "dog", "bird"];
var numbers = 
{
'a':1,
'b':1,
'c':1,
'd':2,
'e':2,
'f':2,
'g':3,
'h':3,
'i':3,
'j':4,
'k':4,
'l':4,
'm':5,
'n':5,
'o':5,

}
//console.log(numbers[3]);
map = "";
// Loop through all the words
for (w in words)
{
	// Split the words into char's
  var split_word = words[w].split("");
  // Loop through each char in split word
  for (s in split_word)
  {
  	// Loop through the numbers object to check for matches
    for (n in numbers)
    {
      //console.log(s + " , " + numbers[n]);
    	if(s == numbers[n])
      {
      	console.log(numbers.length)
      	//console.log(numbers[n]);
        //map += numbers[n]
      }
    }
  }
}


console.log(map);
/* for(w in words)
{
  var split_word = words[w].split("");
  for(i in split_word)
  {
    //console.log(numbers[i]);
    //if(indexOf(split_word[i])
    console.log(indexOf(split_word[i]));
    //console.log(split_word[i]);
  }
  
} */