Hello, I wanted to make this work by using a for function to verify if a word will be same if reversed. This is my secti

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Hello, I wanted to make this work by using a for function to verify if a word will be same if reversed. This is my secti

Post by answerhappygod »

Hello, I wanted to make this work by using a for function to
verify if a word will be same if reversed.
This is my section of code so far I think im getting brainlocked
and cant figure out how to write it.
<!DOCTYPE html>
<html>
<body>
Enter String: <input id="word" />
<p><button
onclick="myFunction();">Check</button>
<div id="result"></div>
<script>
function myFunction() {
var s=document.getElementById("word").value;
var i=1;
var rev;

for(i=string.lenght;i>string.lenght;i--)
if(s==rev)

document.getElementById("result").innerHTML = s+" is
palindrome";
else
document.getElementById("result").innerHTML = s+" is not
palindrome";
}
</script>
</body>
</html>
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply