2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Find the Length of a String
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Find the Length of a String
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
## Hints
|
|
|
|
|
|
|
|
### Hint 1
|
2018-10-12 15:37:13 -04:00
|
|
|
Strings have an <strong>attribute</strong> (feature) called 'length'. All you have to do is tag it after the string / variable.
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
```javascript
|
|
|
|
var str1 = "Hello";
|
|
|
|
var length1 = str1.length; // This returns 5
|
|
|
|
|
|
|
|
var length2 = " Camper".length; // This returns 7 because the space is counted as one character.
|
|
|
|
```
|