Answer to Question #83423 in AJAX | JavaScript | HTML | PHP for Adam Belwood

Question #83423
How to check if word is palindrome using one for loop in javascript? (palindrome examples: "noon", "racecar")
1
Expert's answer
2018-11-29T12:08:11-0500

var str = "helloolleh";

var answer = true;

for(var i = 0, j = str.length - 1; i<j; i++, j--){

if(str[i] != str[j]) {

answer = false;

break;

}

};


if(answer == false){

console.log("This string isnt pallendrom");

}

else console.log("String is pallendrom");

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS