Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

array reverse with for loop

function reverseArray (arr) {
    var newArr = [];
    var inArr = arr;
    console.log(inArr);
    for (i = 0; i < arr.length; i++) {      
        newArr[i] = inArr.pop(i);       
    }   
    return newArr;
}
reverseArray(["A", "B", "C", "D", "E", "F"]);

// OUTPUT: ["F", "D", "E"]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #array #reverse #loop
ADD COMMENT
Topic
Name
6+5 =