1function palindrome(str) {
2
3 var len = str.length;
4 var mid = Math.floor(len/2);
5
6 for ( var i = 0; i < mid; i++ ) {
7 if (str[i] !== str[len - 1 - i]) {
8 return false;
9 }
10 }
11
12 return true;
13}
14
1//Palindrome in Javascript using the stack data structure
2function isPalindrome(word) {
3 let s = new Stack();
4 for (let i = 0; i < word.length; i++) {
5 s.push(word[i]);
6 }
7
8 let rword = "";
9 while (s.length()>0){
10 rword += s.pop();
11 }
12 if (word ==rword){
13 return true
14 } else {
15 return false
16 }
17}