I'm trying to make a challenge, but is not just about the challenge it self but is more about the fact the I would like to understand how to do it.
Given an anagram (string)
: abba
and an array
of words: ['aabb', 'abcd', 'bbaa', 'dada']
To find which one is an anagram and which not.
So I thought I can simply take the string (abba) and with includes
and map
throught it and just splice the false ones.
const res = word.includes(
words.map(item =>
item.split('').map(x => {
return x
})
)
);
console.log('res', res);
But I always get one false cause map just returns the array (i.e.) 'abcd'
and not (i.e.) 'a'
and the 'b'
and so on... so that makes impossible to includes() to actually look into the string
.
How can I solve it??
Where I'm mistaking???
Thanks!