Fix my code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Fix my code

I have a code named Reverse String and I don't know what is wrong, can someone please help?

5th Sep 2017, 11:32 PM
Joe Shanahan
Joe Shanahan - avatar
3 Answers
+ 3
You need to put the code that gets the value etc inside the function also: function change() { var a = document.getElementById("input").value; var string = a; var array = string.split(""); var rarray = array.reverse(); var rstring = rarray.join(""); document.getElementById("result").innerHTML = rstring; } Otherwise it is retrieving the value right after the page is built and it is an empty string.
5th Sep 2017, 11:53 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
I did that but it's still not working please help
6th Sep 2017, 11:27 AM
Joe Shanahan
Joe Shanahan - avatar
+ 1
I just checked it and it's working for me.
6th Sep 2017, 5:11 PM
ChaoticDawg
ChaoticDawg - avatar