Oct. 7 - Oct. 9
A palindrome is a word, number, or phrase that can be read the same backwards and forwards. Some classical palindromes include "race car", "taco cat", and "Amor Roma" which are read the same backwards and forwards (ignoring both spaces and cases).
In this lab, you will develop a palindrome checker that decides whether a string is a palindrome or not.
To get started, first download the ZIP file for Lab 6 here.
In lab6.js, we have provided an empty isPalindrome
function that takes in one parameter,
str
, that should be tested to determine if it is a palindrome. If str
is a palindrome,
the function must return true
; otherwise, it must return false
.
In order to test if a string is a palindrome, we will first clean up the string by making the entire string lowercase. JavaScript provides a built-in function to help us with that:
str = str.toLowerCase();
will make the string lowercase. You should put this statement
as the first line of code inside of your function.
At this point, your string has been cleaned so str
is ready to be checked if it is a palindrome!