The last character
- O(1) · Trivial
- Free
- Python
- JavaScript
- strings
Problem
Write a function that takes a text (with at least one character) and returns its last character.
Examples
"hello" → "o"
"x" → "x"
"Python" → "n"
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def last_char(text):
passJavaScript
function lastChar(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.
More O(1) challenges
- The last digitPython · JavaScript · operations · digits
- The last fourPython · JavaScript · strings · indexes
- The letter gradePython · JavaScript · conditionals · strings · comparisons
- The letters left overPython · JavaScript · strings · operations
- The middle letterPython · JavaScript · strings · indexes
- The name, written rightPython · JavaScript · strings