I want so set data in an object with 2 label positive and negative and I want to set word into the object. I tried this code:
function cok(_class, doc) {
var vocab = {
po: {
wd: "good job"
},
ne: {
wd: "nice job"
}
}
doc = doc.split(' ')
for (var _word of doc) {
console.log(vocab[_class])
}
}
cok('po', 'baik good');
cok('ne', 'jelek nakal');
I have set the positive and negative label but I'm unsure of how to store the value and loop the word.
loop your array like
array.forEach(function(entry) {
entry.po = "positive";
entry.ne = "negative";
});
This will loop and add values into each object