How do you find the length of strings? I am trying to write a project where to activate the if else statement, you have to type your name, and depending on the length of your name, you get a response. The only problem is I don't know how to find the length of stings. Can anyone please help me?
6/12/2017 10:28:19 PM
Cassie Scheidt5 Answers
New AnswerActually Ben, in Java to get string length you use length() with parenthesis. I threw together a code. run it and it will give you the length. remove the parenthesis and it will give you an error. Cassie didn't specify language, but her profile says she is learning Java. https://code.sololearn.com/cMJ5YgyNfldp/?ref=app
In JS length it's a property. So for strings its, string.length Eg: if (string.length < 6) { // code here } else { // code here }
Learn Playing. Play Learning
SoloLearn Inc.
4 Embarcadero Center, Suite 1455Send us a message