0
Reverse a number in js
I want to make a secret message app where they ask you what you want to write but there is a Syntax Error when I call reverse! Whats wrong with code <script> var message = prompt(âWhat do you want to writeâ) var rev = message.reverse() </script> https://code.sololearn.com/WPQR9S6eACjm/?ref=app
2 Answers
+ 4
Try
var rev = message.split("").reverse().join("");
please refer to
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/join
+ 1
Obi O look at this
https://code.sololearn.com/WhD0F594w49Z/?ref=app