Problem
Given a string word, write a solution function that returns true if the string is a palindrome, otherwise returns false.
Palindrome refers to a string that reads the same backward as forward.
Constraints
- The length of
wordis between 1 and 100, inclusive. wordconsists only of lowercase English letters.
Test Cases
| Test Case Number | word | return |
|---|---|---|
| 1 | "racecar" | true |
| 2 | "hello" | false |
| 3 | "level" | true |
Explanation for Test Case 1
- For
word = "racecar", the reversed string is identical to the original, so the return value istrue.
Explanation for Test Case 2
- For
word = "hello", the reversed string is"olleh", which is different from the original, so the return value isfalse.
Explanation for Test Case 3
- For
word = "level", the reversed string is identical to the original, so the return value istrue.