Skip to content

Commit 6f0118b

Browse files
author
Aaron O'Mullan
committed
Update strings course
1 parent da58ce4 commit 6f0118b

6 files changed

Lines changed: 58 additions & 33 deletions

File tree

‎SUMMARY.md‎

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

33
* [Strings](strings/README.md)
4-
* [Basics](strings/basics.md)
4+
* [Creation](strings/create.md)
5+
* [Concatenation](strings/concat.md)
6+
* [Splitting](strings/split.md)
57

‎strings/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# JavaScript Strings
22

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

‎strings/basics.md‎

Lines changed: 0 additions & 32 deletions
This file was deleted.

‎strings/concat.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
---

‎strings/create.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+

‎strings/split.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+

0 commit comments

Comments
 (0)