Advertisement
nikolayneykov

Untitled

Nov 24th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const word = gets();
  2.  
  3. const n = +gets();
  4.  
  5. const checkAnagram = (w1, w2) => {
  6.   const sortedW1 = w1.split('').sort().join('');
  7.   const sortedW2 = w2.split('').sort().join('');
  8.  
  9.   return sortedW1 === sortedW2 ? 'Yes' : 'No';
  10. };
  11.  
  12. for (let i = 0; i < n; i++) {
  13.   const nextWord = gets();
  14.  
  15.   print(checkAnagram(word, nextWord));
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement