i solved the challenge manually by adding property and value then i tried using below code it only works partially. The output is {"apples":25,"oranges":32,"plums":28,"bananas":27,"grapes":27,"strawberries":27} all the newly added properties(bananas,grapes,strawb) has the same value
Your code so far
let foods = {
apples: 25,
oranges: 32,
plums: 28
};
// change code below this line
let arr=['bananas','grapes','strawberries'];
let val=[13,35,27];
for(let i=0;i<arr.length;i++){
for(let j=0;j<val.length;++j){foods[arr[i]]=val[j];}
}
/*foods.bananas=13;
foods.grapes=35;
foods.strawberries=27;*/
//foods.bab
// change code above this line
console.log(JSON.stringify(foods));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36.
you don’t need the inner loop , because the first loop you have can give you the result you need ,
just inject this code foods[arr[i]]=val[i];
every time i increments you can get new property name from arr and new property value from val .