Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions 01-js/medium/palindrome.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/*
Implement a function `isPalindrome` which takes a string as argument and returns true/false as its result.
Note: the input string is case-insensitive which means 'Nan' is a palindrom as 'N' and 'n' are considered case-insensitive.

Once you've implemented the logic, test your code by running
- `npm run test-palindrome`
*/

function isPalindrome(str) {
var str1=str.replace(/[\W_]/g, '').toLowerCase();
var arr=[];
for(var i =str1.length-1;i>=0;i--){
arr.push(str1[i]);
}
var string1 = arr.join('');
if(string1==str1)
return true;
else
return false;
}

module.exports = isPalindrome;