javascript foreach
const avengers = ['thor', 'captain america', 'hulk'];
avengers.forEach((item, index)=>{
console.log(index, item)
})
connect.sonveer
const avengers = ['thor', 'captain america', 'hulk'];
avengers.forEach((item, index)=>{
console.log(index, item)
})
const numbers1 = [45, 4, 9, 16, 25];
const numbers2 = numbers1.map(myFunction);
function myFunction(value, index, array) {
return value * 2;
}
const items = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const anotherItems = items.map(item => item * 2);
console.log(anotherItems);
const numbers = [2, 4, 6, 8];
const result = numbers.map(a => a * 2);
console.log(result);
//Output: [ 4, 8, 12, 16 ]
const originals = [1, 2, 3];
const doubled = originals.map(item => item * 2);
console.log(doubled); // [2, 4, 6]
var r = 4
console.log(r)