JSFiddle - React, Tailwind, and code Playground
by madhawa11111
HTML
<div id="outputDiv"></div>
<div id="apDiv3">
<input type="submit" name="button" id="button" value="Submit" onclick="test()" />
</div>
<div id="apDiv2">
<input type="text" name="palin" id="palin" />
</div>
JavaScript
function test() {
// Assumes: a string is entered into the "palin" text box
// Results: tests if the string is a palindrome and
// returns the conclusion to outputDiv
var word, copy, i;
word = document.getElementById("palin").value.toLowerCase();
copy = "";
i = 0;
while (i < word.length) {
copy = word.charAt(i) + copy;
i=i+1;
}
console.log(copy);
if (word === copy) {
document.getElementById("outputDiv").innerHTML =
document.getElementById("palin").value +
" This is a palindrome!";
} else {
document.getElementById('outputDiv').innerHTML =
document.getElementById('palin').value +
" This is not a palindrome!";
}
}