Answered by : gifted-goshawk-eudx3opebjwh
var arr=[1,2,5,6,2]
arr.reverse()
Source : | Last Update : Fri, 03 Jul 20
Answered by : cautious-cod-xa16zw571wuj
array = [1 2, 3]
reversed = array.reverse()
Source : | Last Update : Thu, 28 Jan 21
Answered by : vikash-kumar
const list = [1,2,3,4,5];
list.reverse(); // It changes the original array
console.log('reversed:', list);
// expected output: "reversed:" Array [5, 4, 3, 2, 1]
Source : | Last Update : Wed, 15 Jun 22
Answered by : naly-moslih
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort();
fruits.reverse();
Source : | Last Update : Sun, 29 May 22
Answered by : mohammad-alshraideh
//The reverse() method reverses the elements in an array.
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.reverse();
//output >> ["Mango", "Apple", "Orange", "Banana"]
//if you find the answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
Source : | Last Update : Sat, 20 Aug 22
Answered by : nic-2vyavjl9ec1i
// reversing an array in javascript is kinda hard. you can't index -1.
// but i can show how you can do it in 4 lines.
var myArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
for (var i = myArray.length - 1; i > 0; i -= 1) { myArray.shift(); myArray.push(i);
}
console.log(myArray); // output: [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
Source : | Last Update : Mon, 22 Nov 21
Answered by : shubham-rajput-gacbh5svogyf
numArr.reverse();
strArr.reverse();
console.log(numArr);
console.log(strArr);
Source : https://stackabuse.com/reverse-an-array-or-list-in-javascript/ | Last Update : Wed, 22 Jun 22
Answered by : chathumal-sangeeth
int[] xr = {1, 2, 3, 4, 5}; System.out.print("["); for (int i = xr.length - 1; i >= 0; i--) { System.out.print(xr[i] + ", "); } System.out.println("\b\b]"); }
Source : | Last Update : Sun, 22 May 22
Answered by : chetan-nada
// reverse array elements in javascript
const arr = ["first", "second", "third"];
arr.reverse(); // Mutates the array
console.log(arr); // ["third", "second", "first"]
Source : | Last Update : Wed, 26 Jan 22
Answered by : mohammad-alshraideh
const reverseArray = (arr)=>{ for (let v = arr.length ; v > 0 ; v--) { return arr[v]; }
}
//if you find this answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
Source : | Last Update : Fri, 19 Aug 22