I'm trying to create a function that takes in two arguments. The first being a word and the second a single letter. I want to return true if the second argument is present in the first and false if it isn't. I'm trying to do this without the .includes() method.
function includes (strA, strB) {
for (let i = 0; i < strA.length; i++) {
if (strA.charAt(i) === strB) {
return 'true'
}else {
return 'false'
}
}
}
includes('awesome', 'e')
Running the code doesn't return anything. Also when i try to console.log() strA[i] or strA.charAt(i) within the for loop only the first letter of strA is logged.
I'm pretty new so any help is appreciated. Thanks.