length of strings | SoloLearn: Learn to code for FREE!

+2

length of strings

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 Scheidt

5 Answers

New Answer

+5

Actually 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

+3

@Justin Hill πŸ‘πŸ‘

+2

In JS length it's a property. So for strings its, string.length Eg: if (string.length < 6) { // code here } else { // code here }

+2

str.length()

0

alert("msg").length