Extra characters and words | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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
Junior
Junior - avatar
7 Respostas
+ 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? William Owens
20th Feb 2022, 12:08 AM
Junior
Junior - avatar
0
It didnt work Jay Matthews
20th Feb 2022, 12:45 AM
Junior
Junior - avatar
0
Can you show me where it goes in the code?
20th Feb 2022, 12:46 AM
Junior
Junior - avatar
0
But what about my length? Where does that go?
20th Feb 2022, 12:51 AM
Junior
Junior - 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
Junior
Junior - 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