I've got values inside array objects and supposed to populate in readable format but stuck as output gets error like "[object Object] undefined".
my desired output is supposed to be like:
Saab - Smodel1,Smodel2,Smodel3, Volvo - Vmodel1,VmodeL2,Vmodel3, BMW - Bmodel1,Bmodel2,Bmodel3,
here is my code:
const cars = [{
"Saab":["Smodel1", "Smodel2", "Smodel3"],
"Volvo":["Vmodel1", "Vmodel2", "Vmodel3"],
"BMW":["Bmodel1", "Bmodel2", "Bmodel3"]
}];
let car_model = '';
for(let i = 0; i < cars.length; i++) {
car_model += cars[i] + "-" + cars[i][i] + "<br/>";
}
added for reference
var cars =
var car, hash;
for (var model in cars) {
car = key;
hash = cars[key];
get(car, hash);
seen(car, hash);
(function loop(car, hash) {
setTimeout(function () {
get(car, hash);
loop(car, hash);
}, 1000);
})(car, hash);
}
Current output: [object Object] undefined