Skip to content

Instantly share code, notes, and snippets.

@mayashavin
Created January 17, 2018 21:22
Show Gist options
  • Save mayashavin/ea6072550a9f01f54d94b9b1d5646518 to your computer and use it in GitHub Desktop.
Save mayashavin/ea6072550a9f01f54d94b9b1d5646518 to your computer and use it in GitHub Desktop.
function isPermutation(strA, strB){
var isValid = true;
//First validity check
if (!strA || !strB || strA.length !== strB.length){
return !isValid;
}
var sortedA = sort(strA), sortedB = sort(strB);
return sortedA === sortedB;
}
function sort(str){
return str.split("").sort().toString();;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment