Answers for "reversed for loop"

PHP
7

js loop backwards

var arr =  [1, 2, 3, 4, 5];
 
for (var i = arr.length - 1; i >= 0; i--) {
    console.log(arr[i]);
}
Posted by: Guest on May-01-2020
1

reverse string with for loop

function reverseString(str) {
    var newString = "";
    for (var i = str.length - 1; i >= 0; i--) {
        newString += str[i];
    }
    return newString;
}
reverseString('hello');
Posted by: Guest on November-18-2020
1

Count Backwards With a For Loop

var myArray = [];
for (var i = 9; i > 0; i -= 2){
    myArray.push(i);
}
console.log(myArray); // console output [ 9, 7, 5, 3, 1 ]
Posted by: Guest on December-21-2020
2

how to reverse loop in javascript

const array = [6,7,8,9,10];
for (const number of array.reverse()) {
    console.log(number);
}
Posted by: Guest on March-25-2020

Browse Popular Code Answers by Language