The following code is meant to build an object from a list of words.
var buildDictionary = function() {
console.log("Buildling Dictionary");
console.log(masterList);
var word, vowelString, dict = {};
for (var i = 0; i < masterList.length; i++) {
word = masterList[i][0];
vowelString = getVowels(masterList[i]);
console.log(vowelString);
if (dict[vowelString] == undefined)
dict[vowelString] = [word];
else
dict[vowelString].push(word);
}
return dict;
}
var dictionary = buildDictionary();
When ran as is, dictionary is an empty object. However, if I manually invoke it...
dictionary = buildDictionary();
It works as expected!
The full code, if relevant, is available here https://jsfiddle.net/4yts4uvr/
Run as iswhat do you mean by that? To execute a function, you must invoke it.Begin rhymer.js:8 Loading CMU Dict... rhymer.js:77 Buildling Dictionary rhymer.js:78 Array[133854]Sorry about the formatting messyness.console.logjust before buildDictionary function declaration, you'll find an empty array