Skip to content

Instantly share code, notes, and snippets.

@abhisheks-12
Created December 21, 2021 06:47
Show Gist options
  • Save abhisheks-12/a2db0e4e242ad2f88b41f93da0ca088a to your computer and use it in GitHub Desktop.
Save abhisheks-12/a2db0e4e242ad2f88b41f93da0ca088a to your computer and use it in GitHub Desktop.
function checkSimilar(str1, str2) {
if (str1.length === str2.length) {
str1.toLowerCase();
str2.toLowerCase();
const tempStr1 = str1.split("").sort();
const tempStr2 = str2.split("").sort();
// console.log(tempStr1);
for (let i = 0; i < tempStr2.length; i++) {
if (tempStr1[i] !== tempStr2[i]) {
return false;
}
}
return true;
}else{
return false;
}
}
const data = checkSimilar("aaand", "daaan");
console.log(data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment