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

19th Feb 2022, 11:52 PM
Your Mom
Your Mom - avatar
7 Answers
+ 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
How do i fix that? [user id=12947447]William Owens[/user]
20th Feb 2022, 12:08 AM
Your Mom
Your Mom - avatar
0
It didnt work [user id=7182385]Jay Matthews[/user]
20th Feb 2022, 12:45 AM
Your Mom
Your Mom - avatar
0
Can you show me where it goes in the code?
20th Feb 2022, 12:46 AM
Your Mom
Your Mom - avatar
0
But what about my length? Where does that go?
20th Feb 2022, 12:51 AM
Your Mom
Your Mom - avatar
0
Okay, what if i wanted to do that in python now? https://code.sololearn.com/cCQAfpI7a7UV/?ref=app
20th Feb 2022, 12:59 AM
Your Mom
Your Mom - 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