Great explanation Justine, especially using the .each API. Since javascript is so versatile, I am adding one more solution which uses iterator from my previous article dev.to/kepta/how-i-learned-to-stop...
.each
function isPalindrome(str) { const iter = [...str.toLowerCase()]; for (let char of iter) { if (char !== iter.pop()) { return false} } return true }
The good thing about this is that it iterates only over half of the string to check if it is palindrome.
Do you have an idea on how you can do permutation of palindrome??
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great explanation Justine, especially using the
.each
API. Since javascript is so versatile, I am adding one more solution which uses iterator from my previous article dev.to/kepta/how-i-learned-to-stop...The good thing about this is that it iterates only over half of the string to check if it is palindrome.
Do you have an idea on how you can do permutation of palindrome??