The Code for TEXT REVERSE


                        //Get the string from the page
                        //controller function
                        function getValue(){
                            document.getElementById("alert").classList.add("invisible");
                            let userString = document.getElementById("userString").value;
                            let revString = reverseString(userString);
                            displayString(revString);
                        }

                        //Reverse the string
                        //logic function
                        function reverseString(userString){
                            let revString = [];
                            //reverse a string using a for loop
                            for (let index = userString.length - 1; index >= 0; index--) {
                                revString += userString[index];
                            }
                            return revString;
                        }

                        //Display the reversed string to the user
                        //View function
                        function displayString(revString){
                            //write to the page
                            document.getElementById("msg").innerHTML = `Your string reversed is: ${revString}`;
                            //show the alert box
                            document.getElementById("alert").classList.remove("invisible");
                        }
                    
                    

getValues()

getValue is a function that listens for a string entered using the JS HTML DOM, ensures that the class invisible is added to the alert box, and then executes two more functions: reverseString and displayString.


reverseString()

reverseString is a function that uses a for loop to get the last item of the userString array (the user input), and then add it to the reverseString array until the index is less than zero.


displayNumbers()

displayString is a function that displays the reversed string using the JS HTML DOM and removes the class invisible from the alert box.