How to reverse array in JavaScript? #20100
-
This is my javascript code. const array = ["car", "tank", "port", "airplane"]. const reverse_array = array.map((array) => {return array}). |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi, kala. const array = ["car", "tank", "port", "airplane"]. const reverse_array = array.reverse().map((array) => {return array}). Thank you. |
Beta Was this translation helpful? Give feedback.
-
Hello. const arr = [1, 2,3] arr.reverser() outuput = [3. 2. 1] |
Beta Was this translation helpful? Give feedback.
-
Note:
|
Beta Was this translation helpful? Give feedback.
Hi, kala.
Why don't you use reverse() function in javascript like follows:
const array = ["car", "tank", "port", "airplane"].
const reverse_array = array.reverse().map((array) => {return array}).
Thank you.