Skip to content

Commit

Permalink
string: palindrome
Browse files Browse the repository at this point in the history
  • Loading branch information
Abid Khan committed Feb 7, 2023
1 parent de6e601 commit beeb2fc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Strings/palindrome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
*
* @param {string[]} str
* @returns {boolean}
*/

function isPalindrome(str){
for(let i = 0; i < str.length / 2; i++){
if(str[i] != str[str.length - 1 - i]){
return false
}
}

return true
}


console.log(isPalindrome("aba"))
console.log(isPalindrome("abaa"))

0 comments on commit beeb2fc

Please sign in to comment.