-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathfunctions.js
47 lines (32 loc) · 798 Bytes
/
functions.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
function greet() {
return("Hello, World!");
}
greet();
console.log(greet());
let hello = () => console.log("Hello, World!");
hello();
let sum = (a, b) => a + b;
console.log(sum(700, 299));
let car = (make, model) => {
return {
make: make,
model: model
}
}
console.log(car("Honda", "Civic"));
/*
IIFE - Immediately Invoked Function Expression
Function that is executed immediately after it is created
*/
(function hey(){
console.log("This is an immediately invoked function expression!");
})();
// IIFE coding challenge - create a function that prints even numbers from 0 to 100
(function even(){
for(let num = 0; num <=100; num++){
if(num%2 == 0){
console.log(num + " is an even number");
}
}
})();
// (function)(); // this is how you call an IIFE