i had create this code fo the function of subLength challenge but the code still return me ‘character is not includes in string’ can someone help me please:
const subLength = (string, char) => {
let count = ;
for(let i = 0; i < string.length; i++) {
if (string[i] === char) {
count.push(i)
if(count.length > 2 || count.length < 2) {
return 0;
}
return count[1]
}
return 'character is not include in string'
}
}
console.log(subLength(‘saturday’,‘a’))