Hello,
I’m working on the palindrome checker and I found a workaround to get the code in the block to persist in the browser after clicking submit.
<form onsubmit="checkForPalindrome(); return false">
If I didn’t include ;return false
then the following code would vanish immediately after flashing in the broswer.
let userInput; // Even this returns to undefined after the click event!
function checkForPalindrome() {
userInput = document.getElementById('text-input').value
console.log(userInput.length)
positiveResult.style.display = 'block';
}
Can someone help me understand why the values I log in the code block do not even remain in global variables?