+ 1
In a string white space are characters as well. Spaces, tabs, ect. This I eat apples is twelve in length.
20th Feb 2022, 12:08 AM
William Owens
William Owens - avatar
0
Alternatively, you can also use array functions const letterCount = str => Array.from( str ).filter( c => c != ' ' ).length; console.log( letterCount( "I eat apples" ) );
21st Feb 2022, 4:31 AM
Ipang