0
Extra characters and words
How do I make it so it doesn’t count spaces? Like when I say “I eat apples” it’ll come out as 12 even tho it’s ten letters https://code.sololearn.com/WNRqiPnw25yD/?ref=app
7 odpowiedzi
+ 1
In a string white space are characters as well. Spaces, tabs, ect. This I eat apples is twelve in length.
0
How do i fix that? William Owens
0
It didnt work Jay Matthews
0
Can you show me where it goes in the code?
0
But what about my length? Where does that go?
0
Okay, what if i wanted to do that in python now?
https://code.sololearn.com/cCQAfpI7a7UV/?ref=app
0
Alternatively, you can also use array functions
const letterCount = str => Array.from( str ).filter( c => c != ' ' ).length;
console.log( letterCount( "I eat apples" ) );