“Foreach di JavaScript” Kode Jawaban

JavaScript foreach

const avengers = ['thor', 'captain america', 'hulk'];
avengers.forEach((item, index)=>{
	console.log(index, item)
})
connect.sonveer

JavaScript foreach

var colors = ['red', 'blue', 'green'];

colors.forEach(function(color) {
  console.log(color);
});
Grepper

Forach Loop di JavaScript

 var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; 
arr.forEach(function(element){
     console.log(element);
 })
kinjal suryavanshi

Indeks Foreach JavaScript

users.forEach((user, index)=>{
	console.log(index); // Prints the index at which the loop is currently at
});
Concerned Chipmunk

Foreach di JavaScript

const avengers = ['IronMan','thor', 'captain america', 'hulk'];
avengers.forEach((item, index)=>{
	console.log(index, item)
})
Doubtful Dogfish

Foreach di JavaScript

<p>forEach() calls a function for each element in an array:</p>

<p>Multiply the value of each element with 10:</p>

<p id="demo"></p>

<script>
const numbers = [65, 44, 12, 4];
numbers.forEach(myFunction)

document.getElementById("demo").innerHTML = numbers;

function myFunction(item, index, arr) {
  arr[index] = item * 10;
}
</script>

forEach() calls a function for each element in an array:

Multiply the value of each element with 10:

650,440,120,40

Precious Pygmy

Jawaban yang mirip dengan “Foreach di JavaScript”

Pertanyaan yang mirip dengan “Foreach di JavaScript”

Lebih banyak jawaban terkait untuk “Foreach di JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya