Same letter at both ends?
- O(1) · Trivial
- Free
- Python
- JavaScript
- strings
- booleans
Problem
Write a function that takes a text (with at least one letter) and returns true if its first letter and its last one are the same. Case doesn't count: with "Alpha" you return true and with "sun", false.
If the text has a single letter, that letter is the first and the last one at the same time, so you return true.
Examples
"test" → true
"sun" → false
With a capital
"Alpha" → true
"garden" → false
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def same_ends(text):
passJavaScript
function sameEnds(text) {
}Solve this challenge
It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.