OneCompiler

Reverse An Array Without Using an Array Method

132

Reverse An Array Without Using an Array Method

Solution:

arr = ['1', '2', '3', '4', 5, 6, 7, 8, 9, 'Pakistan', 'Lahore', null, undefined];

let temp = null;

    for (let i = 0; i <= (arr.length)/2; i++) {
        temp = arr[i]
        arr[i]  = arr[arr.length-(i+1)]
        arr[arr.length-(i+1)] = temp
        
    }
    console.log(arr)