Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

check anagramm in typescript

'use strict';

let text1: string = 'mode';
let text2: string = 'demo';

function anagram(text1: string, text2: string): boolean {
  if (text1.length !== text2.length) {
    return false;
  }
  if (text1 === text2) {
    return false;
  }
  let charString1 = text1.split('').sort().join('');
  let charString2 = text2.split('').sort().join('');

  return charString1 === charString2;
}

console.log(anagram(text1, text2));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #anagramm #typescript
ADD COMMENT
Topic
Name
2+3 =