Created
December 21, 2021 06:47
-
-
Save abhisheks-12/a2db0e4e242ad2f88b41f93da0ca088a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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