GeezerVison is showing github.com — Update strings course · janeshdev/javascript@6f0118b
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 clipboard +3-1Lines changed: 3 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | # Summary |
2 | 2 |
|
3 | 3 | * [Strings](strings/README.md) |
4 | | - * [Basics](strings/basics.md) |
| 4 | + * [Creation](strings/create.md) |
| 5 | + * [Concatenation](strings/concat.md) |
| 6 | + * [Splitting](strings/split.md) |
5 | 7 |
|
Collapse file
Copy file name to clipboard +2Lines changed: 2 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | # JavaScript Strings |
2 | 2 |
|
3 | 3 | JavaScript strings share many similarities with string implementations from other high-level languages, such as Python's. They represent text based messages and data. |
| 4 | + |
| 5 | +In this course we will cover the basics. How to create new strings and perform common operations on them. |
Collapse file
Copy file name to clipboardExpand all lines: strings/basics.md -32Lines changed: 0 additions & 32 deletions 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 | +# Concatenation |
| 2 | + |
| 3 | +Concatenation involves adding two or more strings together, creating a larger string containing the combined data of those original strings. This is done in JavaScript using the **+** operator. |
| 4 | + |
| 5 | +```js |
| 6 | +var bigStr = 'Hi ' + 'JS strings are nice ' + 'and ' + 'easy to add'; |
| 7 | +``` |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +Add up the different names so that the `fullName` variable. Contains John's complete name. |
| 12 | + |
| 13 | +```js |
| 14 | +var firstName = "John"; |
| 15 | +var middleName = "James"; |
| 16 | +var lastName = "Smith"; |
| 17 | + |
| 18 | +var fullName = |
| 19 | +``` |
| 20 | + |
| 21 | +```js |
| 22 | +var firstName = "John"; |
| 23 | +var middleName = "James"; |
| 24 | +var lastName = "Smith"; |
| 25 | + |
| 26 | +var fullName = firstName + " " + middleName + " " + fullName; |
| 27 | +``` |
| 28 | + |
| 29 | +```js |
| 30 | +assert(fullname === 'John James Smith'); |
| 31 | +``` |
| 32 | + |
| 33 | +--- |
Collapse file
Copy file name to clipboard +12Lines changed: 12 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +## Creation |
| 2 | + |
| 3 | +```js |
| 4 | +// Single quotes can be used |
| 5 | +var str = 'Our lovely string'; |
| 6 | + |
| 7 | +// Double quotes as well |
| 8 | +var otherStr = "Another nice string"; |
| 9 | +``` |
| 10 | + |
| 11 | +**Note:** Strings can not be substracted, multiplied or divided. |
| 12 | + |
Collapse file
Copy file name to clipboard +8Lines changed: 8 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +## Splitting |
| 2 | + |
| 3 | +Splitting a string breaks a string up into an array of smaller strings. |
| 4 | + |
| 5 | +```js |
| 6 | +var parts = 'We are separated by spaces'.split(' '); |
| 7 | +``` |
| 8 | + |