Skip to content

Commit 53dbe7c

Browse files
authored
Create palindrome.js
1 parent 1a18bec commit 53dbe7c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

algorithms/palindrome.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function isPalindrome(str){
2+
3+
let isPalindrome = true;
4+
5+
for (let i=0; i < str.length; i++){
6+
7+
8+
if (str[i] === str[str.length - (i+1)]) continue;
9+
10+
else isPalindrome = false;
11+
12+
}
13+
14+
return isPalindrome;
15+
16+
}
17+
18+
isPalindrome('madam');
19+
isPalindrome('shot');

0 commit comments

Comments
 (0)