Skip to content

Commit 2d8cbe0

Browse files
committed
Add introduction about strings: creation
1 parent f7af08a commit 2d8cbe0

File tree

3 files changed

+11
-25
lines changed

3 files changed

+11
-25
lines changed

SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
* [Creation](numbers/create.md)
99
* [Basic Operators](numbers/operators.md)
1010
* [Advanced Operators](numbers/advanced.md)
11-
11+
* [Strings](strings/README.md)
12+
* [Creation](strings/create.md)

strings/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Strings
22

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.
44

55
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+
```

strings/create.md

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Creation
22

3+
You define strings in JavaScript by enclosing the text in single quotes or double quotes:
4+
35
```js
46
// Single quotes can be used
57
var str = 'Our lovely string';
@@ -27,26 +29,3 @@ assert(str === 'abc');
2729
```
2830

2931
---
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-
---

0 commit comments

Comments
 (0)