Skip to content

Instantly share code, notes, and snippets.

@AminBusiness
Created November 9, 2018 03:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AminBusiness/de6b219bca84e3f4bf027419797a3bf1 to your computer and use it in GitHub Desktop.
Save AminBusiness/de6b219bca84e3f4bf027419797a3bf1 to your computer and use it in GitHub Desktop.
<script id="jsbin-javascript">
//Challenge 10 Anagram
//Returns true if anagram is false or not
function isAnagram(str1, str2)
{
return formatStr(str1) === formatStr(str2);
}
function formatStr(str)
{
return str
//replace anything that is not a word character
.replace(/[^\w]/g, ' ')
.toLowerCase()
.split('')
.sort()
.join('')
}
const output = isAnagram('elbow', 'below');
console.log(output);
</script>
<script id="jsbin-source-javascript" type="text/javascript">//Challenge 10 Anagram
//Returns true if anagram is false or not
function isAnagram(str1, str2)
{
return formatStr(str1) === formatStr(str2);
}
function formatStr(str)
{
return str
//replace anything that is not a word character
.replace(/[^\w]/g, ' ')
.toLowerCase()
.split('')
.sort()
.join('')
}
const output = isAnagram('elbow', 'below');
console.log(output);</script>
//Challenge 10 Anagram
//Returns true if anagram is false or not
function isAnagram(str1, str2)
{
return formatStr(str1) === formatStr(str2);
}
function formatStr(str)
{
return str
//replace anything that is not a word character
.replace(/[^\w]/g, ' ')
.toLowerCase()
.split('')
.sort()
.join('')
}
const output = isAnagram('elbow', 'below');
console.log(output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment