im starting a Javascript course and having some trouble with a excersie. i have to use a function smiley with the parameter message. The function should return how many smiley faces are in the message.
so i created this:
function countSmilies(message) {
const smiley = [':)'];
let count = 0;
for (let i = 0; i < message.length; i++) {
for (let j = 0; j < smiley.length; j++) {
if (message[i] === smiley[j]) {
count++;
}
}
}
return count;
}
i get back this:
function should return a correct count of ":)" smilies in a message. : expected 0 to equal 2
Someone can help and explain?
Thanks in advance!