+ 1
In a string white space are characters as well. Spaces, tabs, ect. This I eat apples is twelve in length.
0
Alternatively, you can also use array functions
const letterCount = str => Array.from( str ).filter( c => c != ' ' ).length;
console.log( letterCount( "I eat apples" ) );