See the example code block below for the actual Javascript code used to build this app.
// App Controller / Entry PointfunctiongetValues(){// get the users input// decide what to do with itlet userInput = document.getElementById('message').value;let reversedInput =reverseString(userInput)displayString(reversedInput);}// Business LogicfunctionreverseString(message){// take a string, return it in reverselet reversedMessage =''// reverse the stringfor(let index = message.length -1; index >=0; index = index -1){
reversedMessage += message[index];}return reversedMessage;}// View FunctionfunctiondisplayString(reversedMessage){// show the string on the page / assign text input to reversedMessage
document.getElementById('msg').textContent = reversedMessage;// you want to remove the class d-none to get the alert to show / display
document.getElementById('alert').classList.remove('d-none')}