mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-09-20 07:43:04 +08:00
Create palindrome
This commit is contained in:
parent
76617fa83a
commit
b9ff1b37f5
11
src/algorithms/string/palindrome/palindrome
Normal file
11
src/algorithms/string/palindrome/palindrome
Normal file
@ -0,0 +1,11 @@
|
||||
function checkPalindrome(str){
|
||||
if(str.split('').reverse().join('') == str)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
if (checkPalindrome("madam") !== true)
|
||||
console.log("Test fails: Expected true for input str = 'madam'");
|
||||
else
|
||||
console.log("Sample test case for input str = 'madam' passed!");
|
Loading…
Reference in New Issue
Block a user