Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions LANGS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Language

* [English](./en)
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Learn Javascript

This book will teach you the basics of programming and Javascript. Whether you are an experienced programmer or not, this book is intended for everyone who wishes to learn the JavaScript programming language.

![Screen](./assets/intro.png)
This book has been generated using [GitBook](http://www.gitbook.com) and is open source, feel free to contribute or signal issues on [GitHub](https://github.com/GitbookIO/javascript). You can download a **PDF** or **ePUB** version at [https://www.gitbook.com/book/GitBookIO/javascript](https://www.gitbook.com/book/GitBookIO/javascript).

![Screen](./en/assets/intro.png)

JavaScript (*JS for short*) is the programming language that enables web pages to respond to user interaction beyond the basic level. It was created in 1995, and is today one of the most famous and used programming languages.


**Note:** This book has been generated using [GitBook](http://www.gitbook.io) and is open source, feel free to contribute or signal issues on [GitHub](https://github.com/GitbookIO/javascript). You can download a **PDF** or **ePUB** version at [https://www.gitbook.io/book/GitBookIO/javascript](https://www.gitbook.io/book/GitBookIO/javascript).
1 change: 1 addition & 0 deletions book.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"gitbook": ">1.x.x",
"plugins": [
"exercises"
]
Expand Down
8 changes: 8 additions & 0 deletions en/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Learn Javascript
======

This book will teach you the basics of programming and Javascript. Whether you are an experienced programmer or not, this book is intended for everyone who wishes to learn the JavaScript programming language.

![Screen](./assets/intro.png)

JavaScript (*JS for short*) is the programming language that enables web pages to respond to user interaction beyond the basic level. It was created in 1995, and is today one of the most famous and used programming languages.
File renamed without changes.
1 change: 1 addition & 0 deletions arrays/README.md → en/arrays/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Arrays are a fundamental part of programming. An array is a list of data. We can
The data in arrays are called **elements**.

Here is a simple array:

```javascript
// 1, 1, 2, 3, 5, and 8 are the elements in this array
var numbers = [1, 1, 2, 3, 5, 8];
Expand Down
17 changes: 5 additions & 12 deletions arrays/indices.md → en/arrays/indices.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,24 @@ var fruits = ["apple", "banana", "pineapple", "strawberry"];
// second element. Result: banana = "banana"
var banana = fruits[1];
```
---

{% exercise %}
Define the variables using the indices of the array

```js
{% initial %}
var cars = ["Mazda", "Honda", "Chevy", "Ford"]
var honda =
var ford =
var chevy =
var mazda =
```

```js
{% solution %}
var cars = ["Mazda", "Honda", "Chevy", "Ford"]
var honda = cars[1];
var ford = cars[3];
var chevy = cars[2];
var mazda = cars[0];
```

```js
{% validation %}
assert(honda === "Honda");
assert(ford === "Ford");
assert(chevy === "Chevy");
assert(mazda === "Mazda");
```

---
{% endexercise %}
21 changes: 7 additions & 14 deletions arrays/length.md → en/arrays/length.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,16 @@ var array = [1 , 2, 3];
var l = array.length;
```

---

{% exercise %}
Define the variable a to be the number value of the length of the array

```js
{% initial %}
var array = [1, 1, 2, 3, 5, 8];
var l = array.length;
var a =
```

```js
var a =
{% solution %}
var array = [1, 1, 2, 3, 5, 8];
var l = array.length;
var a = 6;
```

```js
assert (a === 6)
```
---
{% validation %}
assert (a === 6)
{% endexercise %}
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 4 additions & 16 deletions basics/types.md → en/basics/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,10 @@ The most common types are:

JavaScript is a *“loosely typed”* language, which means that you don't have to explicitly declare what type of data the variables are. You just need to use the ```var``` keyword to indicate that you are declaring a variable, and the interpreter will work out what data type you are using from the context, and use of quotes.



---

{% exercise %}
Create a variable named `a` using the keyword `var`.

```js

```

```js
{% solution %}
var a;
```

```js
{% validation %}
a;
```

---
{% endexercise %}
File renamed without changes.
File renamed without changes.
25 changes: 9 additions & 16 deletions conditional/comparators.md → en/conditional/comparators.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,28 @@ Other conditional test:
* ```x```: does x exist?


---

{% exercise %}
Add a condition to change the value of `a` to the number 10 if `x` is bigger than 5.

```js
{% initial %}
var x = 6;
var a = 0;


```

```js
{% solution %}
var x = 6;
var a = 0;

if (x > 5) {
a = 10;
}
```

```js
{% validation %}
assert(a === 10);
```
{% endexercise %}

---
##Logical Comparison
In order to avoid the if-else hassle, simple logical comparisons can be utilised.


In order to avoid the if-else hassle, simple logical comparisons can be utilised.

```js
var topper = (marks > 85) ? "YES" : "NO";
```

In the above example, `?` is a logical operator. The code says that if the value of marks is greater than 85 i.e. `marks > 85` , then `topper = YES` ; otherwise `topper = NO` . Basically, if the comparison condition proves true, the first argument is accessed and if the comparison condition is false , the second argument is accessed.
18 changes: 5 additions & 13 deletions conditional/concatenate.md → en/conditional/concatenate.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ if(country === 'England' || country === 'Germany') {

**Note**: Just like operations on numbers, Condtions can be grouped using parenthesis, ex: ```if ( (name === "John" || name === "Jennifer") && country === "France")```.

---

{% exercise %}
Fill up the 2 conditions so that `primaryCategory` equals `"E/J"` only if name equals `"John"` and country is `"England"`, and so that `secondaryCategory` equals `"E|J"` only if name equals `"John"` or country is `"England"`

```js
{% initial %}
var name = "John";
var country = "England";
var primaryCategory, secondaryCategory;
Expand All @@ -37,9 +35,7 @@ if ( /* Fill here */ ) {
if ( /* Fill here */ ) {
secondaryCategory = "E|J";
}
```

```js
{% solution %}
var name = "John";
var country = "England";
var primaryCategory, secondaryCategory;
Expand All @@ -50,10 +46,6 @@ if (name === "John" && country === "England") {
if (name === "John" || country === "England") {
secondaryCategory = "E|J";
}
```

```js
{% validation %}
assert(primaryCategory === "E/J" && secondaryCategory === "E|J");
```

---
{% endexercise %}
18 changes: 5 additions & 13 deletions conditional/else.md → en/conditional/else.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,24 @@ if(country === 'England') {
```


---

{% exercise %}
Fill up the value of `name` to validate the `else` condition.

```js
{% initial %}
var name =

if (name === "John") {

} else if (name === "Aaron") {
// Valid this condition
}
```

```js
{% solution %}
var name = "Aaron";

if (name === "John") {

} else if (name === "Aaron") {
// Valid this condition
}
```

```js
{% validation %}
assert(name === "Aaron");
```

---
{% endexercise %}
18 changes: 5 additions & 13 deletions conditional/if.md → en/conditional/if.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,20 @@ var message = 'this is ' + country + ', the weather is ' +

**Note:** Conditions can also be nested.

---

{% exercise %}
Fill up the value of `name` to validate the condition.

```js
{% initial %}
var name =

if (name === "John") {

}
```

```js
{% solution %}
var name = "John";

if (name === "John") {

}
```

```js
{% validation %}
assert(name === "John");
```

---
{% endexercise %}
File renamed without changes
File renamed without changes
File renamed without changes.
21 changes: 5 additions & 16 deletions functions/declare.md → en/functions/declare.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,16 @@ var double = function(x) {
};
```

>*Note:* the function above **may not** be referenced before it is defined, just like any other variable.

---
>*Note:* the function above **may not** be referenced before it is defined, just like any other variable.

{% exercise %}
Declare a function named `triple` that takes an argument and returns its triple.

```js

```

```js
{% solution %}
var triple = function(x) {
return x * 3;
}
```

```js
{% validation %}
assert(triple);
assert(triple(4) === 12);
assert(triple(10) === 30);
```

---

{% endexercise %}
18 changes: 5 additions & 13 deletions functions/higher_order.md → en/functions/higher_order.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ double(3); // => 6
triple(3); // => 9
```

---

{% exercise %}
Define a function named `negate` that takes `add1` as argument and returns a function, that returns the negation of the value returned by `add1`. (Things get a bit more complicated ;) )

```js
{% initial %}
var add1 = function (x) {
return x + 1;
};
Expand All @@ -105,9 +103,7 @@ var negate = function(func) {
// Because (5+1) * -1 = -6
negate(add1)(5);

```

```js
{% solution %}
var add1 = function (x) {
return x + 1;
}
Expand All @@ -119,10 +115,6 @@ var negate = function(func) {
}

negate(add1)(5);
```

```js
{% validation %}
assert(negate(add1)(5) === -6);
```

---
{% endexercise %}
File renamed without changes.
18 changes: 5 additions & 13 deletions loops/for.md → en/loops/for.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,21 @@ for(var i = 0; i < 10; i = i + 1){
>***Note***: `i = i + 1` can be written `i++`.


---

{% exercise %}
Using a for-loop, create a variable named `message` that equals the concatenation of integers (0, 1, 2, ...) from 0 to 99.

```js
{% initial %}
var message = "";
```

```js
{% solution %}
var message = "";

for(var i = 0; i < 100; i++){
message = message + i;
}
```

```js
{% validation %}
var message2 = ""

for(var i = 0; i < 100; i++){
message2 = message2 + i;
}
assert(message === message2);
```

---
{% endexercise %}
Loading