TypeScript bootcamp · Lab 45

Palindrome

mediumStrings10 minLesson: Strings

Read the question, write TypeScript on the right, then Run or Check.

QuestionHint and solution stay closed until you open them

yes if word equals reverse.

Examples

Example 1
Input
radar
Output
yes
Example 2
Input
ts
Output
no
Hint
  1. [...w].reverse().join('')
Show correct code

Peek only after you have tried. You can still Check your own version.

const w: string = readLine().trim();
console.log(w === [...w].reverse().join('') ? 'yes' : 'no');
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.