Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 694 Bytes

isAnagram.md

File metadata and controls

25 lines (17 loc) · 694 Bytes
  • An anagram is the result of rearranging the letters of a word to produce a new word.

Note: anagrams are case insensitive

  • Complete the function to return true if the two arguments given are anagrams of each other; return false otherwise.

Samples:

  • "foefet" is an anagram of "toffee"

  • "Buckethead" is an anagram of "DeathCubeK"

Solution:

var isAnagram = function (test, original) {
  return test.toLowerCase().split("").sort().join("") ==
    original.toLowerCase().split("").sort().join("")
    ? true
    : false;
};

console.log(isAnagram("foefet", "toffee")); // true