I'm trying to accomplish a task similar to this:
If the array [ "a", "b", "c" ] includes any of the characters in the constant word = "abracadabra", I want to retrieve that character along with its position in const word.
My attempt so far looks like this:
const word = "abracadabra";
const input = ["a", "b", "c"];
for (let i = 0; i< word.length; i++) {
if (input.includes(word(i))) {
console.log(i + (word(i)));
}
}
However, it's not working as expected. Can someone assist me with the logic and syntax? I am new to coding, thank you for your time and help!