Skip to main content

Archive

Show more

How to apply foreach loop on an array in javascript

how-to-apply-foreach-loop-on-array-in-javascript


Question: How to apply foreach loop on an array in javascript

Answer:

const myArray = ["Green", "Red", "Black", "White"];
myArray.forEach((entry) => {
    console.log(entry);
});

Output:

Green
Red
Black
White


We try to provide you the best content, if there is any mistake in this article or there is any mistake in code, then let us know.

Comments