Instead of this
if (string.indexOf('l')) {
newString += 1;
}
You can use charAt or even direct indexing to check each letter of a string.
Like this
if (letter[i] == 'l') {
newString += 1;
}
or this
if (letter.charAt(i) == 'l') {
newString += 1;
}
Here's a FIDDLE
Note that if you were to use indexOf
you'd want to call it directly on the string in question, like this
letter.indexOf('l')