TypeScript bootcamp · Lab 46

Anagram check

mediumStrings12 minLesson: Strings

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

QuestionHint and solution stay closed until you open them

Two words; yes if anagrams ignore case.

Examples

Example 1
Input
listen silent
Output
yes
Hint
  1. sort letters
Show correct code

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

const [a, b] = readLine().trim().split(/\s+/);
const norm = (s: string) => [...s.toLowerCase()].sort().join('');
console.log(norm(a) === norm(b) ? 'yes' : 'no');
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.