“loop javascript melalui array” Kode Jawaban

loop javascript melalui array

var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
    console.log(colors[i]);
}
Grepper

loop javascript melalui array

var colors = ["red","blue","green"];
colors.forEach(function(color) {
  console.log(color);
});
Gifted Gerenuk

loop javascript melalui array

const myArray = ['foo', 'bar'];

myArray.forEach(x => console.log(x));

//or

for(let i = 0; i < myArray.length; i++) {
  console.log(myArray[i]);
}
MrGeeDee

loop javascript melalui array

let array = ['Item 1', 'Item 2', 'Item 3'];

for (let item of array) {
  console.log(item);
}
garzj

loop javascript melalui array

const array = ["one", "two", "three"]
array.forEach(function (item, index) {
  console.log(item, index);
});
Wild Warbler

loop javascript melalui array

const numbers = [1, 2, 3, 4]
numbers.forEach(number => {
	console.log(number);
}

for (let i = 0; i < number.length; i++) {
	console.log(numbers[i]);
}
krylic

loop javascript melalui array

var myStringArray = ["hey","World"];
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++) {
    console.log(myStringArray[i]);
    //Do something
}
Bald Eagle

loop javascript melalui array

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

array1.forEach(element => console.log(element));
Tame Turkey

loop javascript melalui array

array.forEach(item => console.log(item));
Ill Ibis

loop javascript melalui array

var numbers = [1, 2, 3, 4, 5];
numbers.forEach((Element) => console.log(Element));
hateschoollovecoding

Jawaban yang mirip dengan “loop javascript melalui array”

Pertanyaan yang mirip dengan “loop javascript melalui array”

Lebih banyak jawaban terkait untuk “loop javascript melalui array” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya