TypeScript bootcamp · Lab 07

Reverse a word

mediumStrings10 minLesson: Strings

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

QuestionHint and solution stay closed until you open them

Read one word typed as string. Log it reversed.

Examples

Example 1
Input
code
Output
edoc
Example 2
Input
TS
Output
ST
Hint
  1. [...word].reverse().join("")
Show correct code

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

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