Hi I'm trying to sum the values I have in 3 json objects.
var things = {
"noun": {
"syn": ["belongings", "holding", "stuff", "property"]
}
};
var stuff = {
"noun": {
"syn": ["belongings", "holding", "property"]
}
};
var crap = {
"noun": {
"syn": ["things", "holding", "waste"]
}
};
result = {};
word1 = things.noun.syn
for (key in word1) {
nk = word1[key];
if (result.nk == undefined) {
result.nk = 1
} else {
result.nk = result.nk + 1;
}
}
console.log(result);
The result I am getting is result.nk instead of result.belongings for example.
I've been screwing around in a jsfiddle: http://jsfiddle.net/qunUz/2/
How do I sum the amount of times each value appears?
word1is an array...