119 let positive = 0;
120 let negative = 0;
121
122 sentiments_list.map((sentiment) => {123 if (sentiment.sentiment >= 50) {
124 positive += 1;
125 } else {
114 let positive = 0;
115 let negative = 0;
116
117 sentiments_list.map((sentiment) => {118 if (sentiment.sentiment >= 50) {
119 positive += 1;
120 } else {
Array
has several methods for filtering, mapping, and folding.
If we forget to write return statement in a callback of those, it's probably a mistake.
If you don't want to use a return
or don't need the returned results, consider using .forEach
instead.
const indexMap = myArray.reduce(function(memo, item, index) {
memo[item] = index;
}, {});
const foo = Array.from(nodes, function(node) {
if (node.tagName === "DIV") {
return true;
}
});
const bar = foo.filter(function(x) {
if (x) {
return true;
} else {
return;
}
});
const indexMap = myArray.reduce(function(memo, item, index) {
memo[item] = index;
return memo;
}, {});
const foo = Array.from(nodes, function(node) {
if (node.tagName === "DIV") {
return true;
}
return false;
});
const bar = foo.map(node => node.getAttribute("id"));