Read the question, write JavaScript on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read one word and log yes if it reads the same forwards and backwards, otherwise no.
Ignore case: Level should count as a palindrome.
Input. One line: a word.
Output. yes or no (lowercase).
Examples
Input
Level
Output
yes
Input
python
Output
no
Hint
- Lowercase first so case does not break the comparison.
- Compare the word to its reversed form.
Show correct code
Peek only after you have tried. You can still Check your own version.
const s = readLine().trim().toLowerCase();
const rev = [...s].reverse().join("");
console.log(s === rev ? "yes" : "no");
main.jsconsole.log · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.