+ 2

Reversing a String in JavaScript

How would one reverse a String in JavaScript?

22nd Mar 2018, 8:48 PM
Leroy Jenkins
Leroy Jenkins - avatar
1 ответ
+ 5
var string = “yourString”; var stringArray = string.split(“”); stringArray.reverse(); string = stringArray.join(“”); Or to shorten it string = string.split(“”).reverse().join(“”);
22nd Mar 2018, 8:58 PM
Ariela
Ariela - avatar