JavaScript: Reverse the elements of a given array of integers length 3
JavaScript Basic: Exercise-73 with Solution
Reverse Elements of Array (Length 3)
Write a JavaScript program to reverse the elements of a given array of integers of length 3.
The program reverses the order of elements in an array of integers of length 3. It swaps the first and last elements, resulting in the array being in reverse order from its original state.
Visual Presentation:

Sample Solution:
JavaScript Code:
Output:
[3,4,5] [-1,0,1] [1,3,2]
Live Demo:
Flowchart:

ES6 Version:
For more Practice: Solve these Related Problems:
- Write a JavaScript program that reverses the order of elements in a three-element array without using the built-in reverse() method.
- Write a JavaScript function that swaps the first and third elements of a length-3 array to achieve a reversed order.
- Write a JavaScript program that takes an array of three numbers and outputs a new array with the elements in reverse order using manual iteration.
Go to:
PREV : Check if First and Last Elements Are Same.
NEXT : Set All Elements to Largest of First/Last in Array.
Improve this sample solution and post your code through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.