The Code for Backtrack

                        
                            function getString() {
                                var targetString = document.getElementById("targetString").value;
                                return targetString;
                            }
                            
                            function reverseString() {
                                var targetString = getString();
                                var targetStringReverse = ""
                            
                                for(let i = targetString.length - 1; i >= 0; i--) {
                                    targetStringReverse += targetString[i];
                                };
                            
                                return targetStringReverse;
                            }
                            
                            function printReverseString() {
                                var printHeader = document.getElementById("results");
                                
                                printHeader.innerHTML = reverseString();
                            }
                        
                    

The Code is structed in three functions.

getString()

getString() retrieves the input string for reversal.

reverseString()

reverseString() iterates through the input string backward and generates a new string with this sequence of characters.

printReverseString()

printReverseString() displays the reversed string to the page.