Created
December 31, 2019 11:48
-
-
Save Hellodhakad/e0792d8d035d7852b60fc4b74df7c2c4 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 isomorphicString(str1, str2){ | |
if(str1.length == str2.length){ | |
var newMap = new Map(); | |
for(let i=0; i< str1.length; i++){ | |
let newKey = str1[i].toString(); | |
console.log(newKey) | |
let mapValue = newMap.newKey; | |
if(mapValue){ | |
console.log(mapValue) | |
if(mapValue == str2[i]){ | |
continue; | |
}else{ | |
console.log('Strings are not isomorphic!') | |
return false | |
} | |
}else{ | |
newMap.str1[i] = str2[i]; | |
} | |
} | |
}else{ | |
console.log('Strings are not isomorphic!') | |
return false | |
} | |
} | |
isomorphicString('egg', 'add') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment