GeezerVison is showing github.com — <Add article about string length · reenadhawan1/javascript@69e104b
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: SUMMARY.md +2-1Lines changed: 2 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
10 | 10 | * [Advanced Operators](numbers/advanced.md) |
11 | 11 | * [Strings](strings/README.md) |
12 | 12 | * [Creation](strings/create.md) |
13 | | - * [Concatenation](strings/concat.md) |
| 13 | + * [Concatenation](strings/concat.md) |
| 14 | + * [Length](strings/length.md) |
Collapse file
Copy file name to clipboard +33Lines changed: 33 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +# Length |
| 2 | + |
| 3 | +It's easy in Javascript to know how many characters are in string using the property `.length`. |
| 4 | + |
| 5 | +```js |
| 6 | +// Juste use the property .length |
| 7 | +var size = 'Our lovely string'.length; |
| 8 | + |
| 9 | +``` |
| 10 | + |
| 11 | +**Note:** Strings can not be substracted, multiplied or divided. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +Store in the variable named `size` the length of `str`. |
| 16 | + |
| 17 | +```js |
| 18 | +var str = "Hello World"; |
| 19 | + |
| 20 | +var size = |
| 21 | +``` |
| 22 | + |
| 23 | +```js |
| 24 | +var str = "Hello World"; |
| 25 | + |
| 26 | +var size = str.length; |
| 27 | +``` |
| 28 | + |
| 29 | +```js |
| 30 | +assert(size == str.length); |
| 31 | +``` |
| 32 | + |
| 33 | +--- |