490,973 views
9 votes
9 votes
Develop an algorithm and draw a flowchart to determine and input number is palindrome or not.​

User Matthew Layton
by
2.8k points

1 Answer

4 votes
4 votes

function checkPalindrome(str){
let reversed = str.split("").reverse().join("")
return str === reversed
}
let str1 = "anna"
let str2 = "banana"
let str3 = "kayak"
checkPalindrome(str1)
// -> true
checkPalindrome(str2)
// -> false
checkPalindrome(str3)
// -> true
User Soumik Rakshit
by
2.5k points