Skip to content

Commit

Permalink
Add introduction about strings: creation
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyPesse committed Apr 2, 2014
1 parent f7af08a commit 2d8cbe0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 25 deletions.
3 changes: 2 additions & 1 deletion SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
* [Creation](numbers/create.md)
* [Basic Operators](numbers/operators.md)
* [Advanced Operators](numbers/advanced.md)

* [Strings](strings/README.md)
* [Creation](strings/create.md)
8 changes: 7 additions & 1 deletion strings/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Strings

JavaScript strings share many similarities with string implementations from other high-level languages, such as Python's. They represent text based messages and data.
JavaScript strings share many similarities with string implementations from other high-level languages. They represent text based messages and data.

In this course we will cover the basics. How to create new strings and perform common operations on them.

Here is an example of a string:

```javascript
"Hello World"
```
25 changes: 2 additions & 23 deletions strings/create.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Creation

You define strings in JavaScript by enclosing the text in single quotes or double quotes:

```js
// Single quotes can be used
var str = 'Our lovely string';
Expand Down Expand Up @@ -27,26 +29,3 @@ assert(str === 'abc');
```

---

### Transforming objects to strings with .toString()

Most javascript objects such as `Number`s can be transformed into strings using the `.toString()` method.

---

Create a variable named `numstr` that is a string transformed from the `num` variable.

```js
var num = 27;
```

```js
var num = 27;
var numstr = 27.toString();
```

```js
assert(numstr === '27');
```

---

0 comments on commit 2d8cbe0

Please sign in to comment.