The Code for REwind.

                        // Get the string entered
                        function getInput() {
                            let input = document.getElementById("userString").value;
                            let reversedString = reverseString(input);
                        // Reverse the string
                        function reverseString(userString) {
                            let reversed = [];
                            //Reverse string using a for loop - Method 1
                            for(let i = 0; i < userString.length; i++) {
                                reversed += userString[(userString.length - 1) - i];
                            // Reverse string using a for loop - Method 2
                            //for(let i = userString.length - 1; i >= 0; i--) {
                            //    reversed += userString[i];
                            return reversed;
                        // Display the reversed string
                        function displayString(outputString) {
                            //Write message to the page
                            document.getElementById("msg").innerHTML = `Your string reversed is: ${outputString}`;
                            // Show alert box

REwind is a JavaScript coding challenge. We ask the user to enter a string, and then we reverse it.


We use the JavaScript document API to get the string entered by the user. Next we call the reverseString() function to reverse the string that the user provided. After that we call the displayString() method to output the result.


We use a for loop to reverse the string that the user entered.


We use the JavaScript document API innerHTML property to insert the reversed string onto the page. Then we set the Bootstrap alert to visible so that the message can be seen.