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

28 lines
584 B
JavaScript

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
}
}
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"));