I have an array of names and another one with JSON data accessible through a method. I attempted to carry out the following:
let out = [];
for (let i = 0; i < data.length; i++) {
for (let j = 0; j < names.length; j++) {
let feed = {[names[j]] : getData(data[i])};
out.push(feed);
}
}
The expected result would look something like this:
[{"jonas": {"a": 1, "b": 2}}, {"lara" : {"a": 73, "b": 0}}, "jakob": {"a": null, "b": "something"}]
However, what actually occurred was an error: unexpected token '[' The problem stemmed from the '[' at ...let feed = {names[ /←this here/ j]...