challenge-algorithms-v2.0/08-isAnagram/index.js

28 lines
584 B
JavaScript
Raw Normal View History

2022-11-01 00:44:16 +00:00
const isAnagram=(word='', word2='')=>{
let arr = []
let newString = ''
let i=0
for(i=0; i<=word.length-1; i++){
arr.push(word[i])
}
arr = arr.reverse()
i = 0
for(i=0; i<=word.length-1; i++){
newString+=arr[i]
}
if(word2 == newString){
return true
}
else{
return false
}
2022-11-01 00:44:16 +00:00
}
console.log(isAnagram("roma", "amor"));
console.log(isAnagram("Buckethead", "DeathCubeK"));
console.log(isAnagram("Twoo", "WooT"));
console.log(isAnagram("dumble", "bumble"));
console.log(isAnagram("ound", "round"));
console.log(isAnagram("apple", "pale"));