This code is structured in three functions.

The first thing done was to add an event listener to the button so the code will fire when the button is pressed.

The next getValue function gets the value from the text input field, then it will call on a couple of "helper" functions explained below.

The first helper function is called reverseString. This function will first check to make sure at least two characters were entered. Then it will loop through the characters entered in the text field backwards from the last character to the first, and then concatenate them into a string. Finally it will pass on this reverse string to the next displayString helper function.

The next helper function is called displayString. This will take the string passed to it from the reverseString helper function, put them in some html code, and then inject them into the web page for display.

In summary the getValue function gets the value from the text field, it calls the reverseString function to reverse the text, then it calls the displayString function to display the reversed string passed on from the reverseString function into the web page.


Application Website

Git Repo