Wednesday, July 19, 2017

freecodecamp: Checking for Palindromes #js: #100daysofcode #vanillajs

#freecodecamp #javascript #loop #string

GoalReturn true if the given string is a #palindrome. Otherwise, return false.

A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.
You'll need to remove punctuation and turn everything lower case in order to check for palindromes.
We'll pass strings with varying formats, such as "racecar", "RaceCar", and "race CAR" among others.

How it got done: Using Reg Ex, all uppercase letter where replaced as lowercase letters. Then we check if the string is the same forward and backwards using split() to separate the original string into indivdual characters, finally reversing it and then putting it back together again.

No comments: