Answers for "for each loop syntax"

20

javascript for each loop

var colors = ["red", "blue", "green"];
colors.forEach(function(color) {
    console.log(color);
});
Posted by: Guest on July-19-2019
3

for each java

public class ForEachLoopExample
{
   public static void main(String[] args)
   {
      int[] numbers = {2, 4, 6, 8, 10};
      // for each loop
      for(int n : numbers)
      {
         System.out.println(n);
      }
   }
}
Posted by: Guest on October-23-2020
3

for each

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

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

// expected output: "a"
// expected output: "b"
// expected output: "c"
Posted by: Guest on April-08-2020
0

javascript for each loop

const a = ["a", "b", "c"];
for (const val of a) { // You can use `let` instead of `const` if you like
    console.log(val);
}
Posted by: Guest on August-31-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language