forked from aerian-studios/modern-js-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
96 lines (56 loc) · 1.81 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
let greeting = "hello world";
console.log(greeting);
greeting = "hello everyone";
console.log(greeting);
let apples = 10;
const fruit = "apples";
console.log(apples + " " + fruit);
apples = apples + 1;
console.log(apples + " " + fruit);
console.log(typeof fruit);
const typesOfFruit = ["apple", "orange", "pear", "banana"];
console.log(typesOfFruit);
console.log(typesOfFruit[0]);
console.log(typesOfFruit.length);
console.log(typesOfFruit[4]);
typesOfFruit[9] = 20;
console.log(typesOfFruit[9]);
console.log(typesOfFruit);
console.log("I have " + typesOfFruit.length + " types of fruit, and the first one is " + typesOfFruit[0]);
console.log(`I have ${typesOfFruit.length} types of fruit, and the first one is ${typesOfFruit[0]}`);
const myFavourites = {
fruit: "passion fruit",
vegetable: "artichoke",
number: 3.1415,
androidVersion: "pie",
unicodeRange: "emoji",
list: typesOfFruit,
length: 2
}
console.log(`My favourite fruit is ${ myFavourites.fruit }`);
console.log(myFavourites);
console.log(myFavourites.length);
const thing = "fruit";
console.log(myFavourites[thing]);
const greet = function (person) {
console.log(`Hello ${person}`)
}
myFavourites.action = greet;
greet("Gyula");
greet("Ben");
greet("Jason");
greet();
console.log(myFavourites);
const enhance = (myNumber) => myNumber + 1000;
const fruitPerDay = 5;
const moreFruit = enhance(fruitPerDay);
console.log(`I used to eat ${fruitPerDay} pieces of fruit per day, but now I eat ${moreFruit}`);
const myFavouriteMovies = {
action: "Starship Troopers",
scifi: "Starship Troopers",
comedy: "Starship Troopers",
romance: "Starship Troopers",
satire: "Starship Troopers"
}
const chooseAFilm = (genre) => myFavouriteMovies[genre];
console.log("Tonight we will be watching " + chooseAFilm("comedy"));