Answers for "javascript foreach push to array"

2

es6 forEach

const array1 = ['a', 'b', 'c'];

array1.forEach((element) => {
  console.log(element)
});

// expected output: "a"
// expected output: "b"
// expected output: "c"
Posted by: Guest on August-25-2020
23

foreach jas

const array1 = ['a', 'b', 'c'];

array1.forEach(element => console.log(element));
Posted by: Guest on January-10-2020
0

how to append item to an array in foreach javascript

for (var i = 0; i < a.length; i++) {
    if (a[i] == 1) a.push(5);
    console.log(a[i]);
}
Posted by: Guest on December-29-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language