Skip to content

Commit 6409b93

Browse files
committed
chapter 01 examples
1 parent 5761b02 commit 6409b93

File tree

4 files changed

+14
-60
lines changed

4 files changed

+14
-60
lines changed

chapter01/02-Variables.js

+1-49
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,6 @@ console.log("price: "+ price);
1414
console.log("nullVar: "+ nullVar);
1515
console.log("und: "+ und);
1616

17-
//******* EcmaScript 6: let and const keywords
18-
// EcmaScript 6 Constants
19-
const PI = 3.141593;
20-
//PI = 3.0; //throws error
21-
console.log(PI);
22-
23-
// EcmaScript 6: let is the new var
24-
var framework = 'Angular';
25-
var framework = 'React';
26-
console.log(framework);
27-
28-
let language = 'JavaScript!';
29-
//let language = 'Ruby!'; //throws error
30-
console.log(language);
31-
3217
//******* Variable Scope
3318

3419
var myVariable = 'global';
@@ -49,37 +34,4 @@ console.log(myFunction()); //{2}
4934

5035
console.log(myOtherVariable); //{3}
5136
console.log(myOtherFunction()); //{4}
52-
console.log(myOtherVariable); //{5}
53-
54-
//******* EcmaScript 6: variables scope
55-
let movie = 'Lord of the Rings';
56-
//var movie = 'Batman v Superman'; //throws error, variable movie already declared
57-
58-
function starWarsFan(){
59-
let movie = 'Star Wars';
60-
return movie;
61-
}
62-
63-
function marvelFan(){
64-
movie = 'The Avengers';
65-
return movie;
66-
}
67-
68-
function blizzardFan(){
69-
let isFan = true;
70-
let phrase = 'Warcraft';
71-
console.log('Before if: ' + phrase);
72-
if (isFan){
73-
let phrase = 'initial text';
74-
phrase = 'For the Horde!';
75-
console.log('Inside if: ' + phrase);
76-
}
77-
phrase = 'For the Alliance!';
78-
console.log('After if: ' + phrase);
79-
}
80-
81-
console.log(movie);
82-
console.log(starWarsFan());
83-
console.log(marvelFan());
84-
console.log(movie);
85-
blizzardFan();
37+
console.log(myOtherVariable); //{5}

chapter01/08-Functions.js

-11
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,6 @@ var result = sum(1,2);
2424
output(result);
2525

2626

27-
//ES6: arrow functions
28-
let circleArea = (r) => {
29-
const PI = 3.14;
30-
let area = PI * r * r;
31-
return area;
32-
}
33-
console.log(circleArea(2));
34-
35-
let circleArea2 = (r) => 3.14 * r * r;
36-
console.log(circleArea2(2));
37-
3827

3928

4029

chapter01/11-ES6letconst.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**
2+
* Created by loiane on 1/10/16.
3+
*/

chapter01/13-Es6StringTemplates.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head lang="en">
4+
<meta charset="UTF-8">
5+
<title></title>
6+
</head>
7+
<body>
8+
9+
</body>
10+
</html>

0 commit comments

Comments
 (0)