loop array of numbers code example
Example 1: iterate through array js
let arbitraryArr = [1, 2, 3];
// below I choose let, but var and const can also be used
for (let arbitraryElementName of arbitraryArr) {
console.log(arbitraryElementName);
}
Example 2: arrays with for loops
// For-All variant
// Go through the elements backwards
// by adjusting the for-loop
public void forAllBackwards(int[] nums) {
for (int i = nums.length-1; i>=0; i--) {
System.out.println( nums[i] );
}
}