Q:

Write a JavaScript program to reverse the elements of a given array of integers length 3

0

Write a JavaScript program to reverse the elements of a given array of integers length 3.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

function reverse3(array) {
    return array.map((element, idx, arr) => arr[(arr.length - 1) - idx]);
}
console.log(reverse3([5, 4, 3])); 
console.log(reverse3([1, 0, -1]));  
console.log(reverse3([2, 3, 1]));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now