javascript use stack to check palindrome code example
Example: palindrome javascript stack
//Palindrome in Javascript using the stack data structure
function isPalindrome(word) {
let s = new Stack();
for (let i = 0; i < word.length; i++) {
s.push(word[i]);
}
let rword = "";
while (s.length()>0){
rword += s.pop();
}
if (word ==rword){
return true
} else {
return false
}
}