The Code
function getString() {
document.getElementById("alert").classList.add("invisible");
let userString = document.getElementById("userString").value;
let revString = reverseString(userString);
displayString(revString);
}
getString()
Requirements:
- Function that accesses the webpage and get the values from inputs
- Checks for:
- reset the alert in the results to invisible
- set up the system
Variables:
- userString => string that
- revString => values where the count ends
function reverseString(userString) {
let revString = [];
for (let index = userString.length - 1; index >= 0; index--) {
revString += userString[index];
}
return revString;
}
reverseString()
Requirements:
- Reverse the string using a for loop
Variables:
- revString => values to start the count
function displayString(revString) {
document.getElementById("msg").innerHTML = `Your string reversed is: ${revString}`;
document.getElementById("alert").classList.remove("invisible");
}
reverseString()
Requirements:
- Function that reversed the string and displays it to the user
- Write the message to the page
- Show the alert box