Hello everyone, I am trying to put together a simple application that checks if a word is a palindrome or not and then adds the word to a list that either says Is a palindrome or is not a palindrome. I am trying to solve this without using JQuery. My question is what should I add to the JS to push the word into a list on the HTML page and what should I add to make the submit button start the function. Thanks for all of your time and help.
Here is my JS:
const palindrome = function(str){
for(var i = 0; i<str.length; i++){
for (var j= str.length - 1; j >= 0; j--){
if (str[i] === str[j]){
return "Is a palindrome"
}
else {
return "Is not a palindrome"
}
}
}
};
Here is my HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<title>palindrome</title>
<style>
/* CSS */
</style>
<script>
// JAVASCRIPT
</script>
</head>
<body>
<h1>IS THIS A PALINDROME?!</h1>
<form>
<!--field for word input-->
<form>
<input type = "text"><br>
<input type="submit" value="Submit">
</form>
<!--lists of palindromes/non palindromes-->
</body>