using stack how do you check if a string is a palindrome javascript 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
}
}