Answers for "create an object in javascript from a loop"

85

javascript loop through object

Object.entries(obj).forEach(
    ([key, value]) => console.log(key, value)
);
Posted by: Guest on February-15-2020
-1

js create jaon object from for loop

var loop = [];

for(var x = 0; x < 10; x++){
 loop.push({value1: "value_a_" + x , value2: "value_b_" + x});
}

JSON.stringify({array: loop});
Posted by: Guest on February-18-2021

Code answers related to "create an object in javascript from a loop"

Code answers related to "Javascript"

Browse Popular Code Answers by Language