Answers for "iterate in js"

2

javascript iterate

var obj = {a: 1, b: 2, c: 3};

for (const prop in obj) {
  console.log(`obj.${prop} = ${obj[prop]}`);
}

// Output:
// "obj.a = 1"
// "obj.b = 2"
// "obj.c = 3"
Posted by: Guest on September-11-2021
21

for in loop javascript

var person = {"name":"taylor","age":31};
for (property in person) {
	console.log(property,person[property]);
}
//name taylor
//age 31
Posted by: Guest on January-17-2020
2

Iterate with JavaScript For Loops

var myArray = [];
for (var i = 1; i <= 5; i++){
    myArray.push(i);
} 
console.log(myArray) // console output [ 1, 2, 3, 4, 5 ]
Posted by: Guest on December-21-2020
0

Javascript Iteration

//The forEach() method calls a function (a callback function) once for each array element.const numbers = [45, 4, 9, 16, 25];

let txt = "";
numbers.forEach(myFunction);

function myFunction(value, index, array) {
  txt += value + "<br>";
}
Posted by: Guest on November-05-2021

Python Answers by Framework

Browse Popular Code Answers by Language