GeezerVison is showing github.com — Add introduction about strings: creation · codex-academy/javascript@2d8cbe0
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 |
|---|
|
8 | 8 | * [Creation](numbers/create.md) |
9 | 9 | * [Basic Operators](numbers/operators.md) |
10 | 10 | * [Advanced Operators](numbers/advanced.md) |
11 | | - |
| 11 | +* [Strings](strings/README.md) |
| 12 | + * [Creation](strings/create.md) |
Collapse file
Copy file name to clipboard +7-1Lines changed: 7 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | # Strings |
2 | 2 |
|
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. |
| 3 | +JavaScript strings share many similarities with string implementations from other high-level languages. They represent text based messages and data. |
4 | 4 |
|
5 | 5 | In this course we will cover the basics. How to create new strings and perform common operations on them. |
| 6 | + |
| 7 | +Here is an example of a string: |
| 8 | + |
| 9 | +```javascript |
| 10 | +"Hello World" |
| 11 | +``` |
Collapse file
Copy file name to clipboard +2-23Lines changed: 2 additions & 23 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | ## Creation |
2 | 2 |
|
| 3 | +You define strings in JavaScript by enclosing the text in single quotes or double quotes: |
| 4 | + |
3 | 5 | ```js |
4 | 6 | // Single quotes can be used |
5 | 7 | var str = 'Our lovely string'; |
@@ -27,26 +29,3 @@ assert(str === 'abc'); |
27 | 29 | ``` |
28 | 30 |
|
29 | 31 | --- |
30 | | - |
31 | | -### Transforming objects to strings with .toString() |
32 | | - |
33 | | -Most javascript objects such as `Number`s can be transformed into strings using the `.toString()` method. |
34 | | - |
35 | | ---- |
36 | | - |
37 | | -Create a variable named `numstr` that is a string transformed from the `num` variable. |
38 | | - |
39 | | -```js |
40 | | -var num = 27; |
41 | | -``` |
42 | | - |
43 | | -```js |
44 | | -var num = 27; |
45 | | -var numstr = 27.toString(); |
46 | | -``` |
47 | | - |
48 | | -```js |
49 | | -assert(numstr === '27'); |
50 | | -``` |
51 | | - |
52 | | ---- |