-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
49 lines (32 loc) · 1.02 KB
/
script.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
'use strict';
// function logger(){
// console.log('this is first function');
// }
// //calling the function
// logger();
// //function with parameters
// function selection(make, made){
// console.log(`This is the ${make} and ${made} we are expecting`);
// }
// selection('Toyota', 'Audi');
// //function declaration
// function checking(){
// console.log('This is function declaration');
// }
// checking();
// //for function declaration we can call them before or after the function declaration
// //function expression
// const valuables2 = function(){
// console.log('This is function expression');
// }
//here we are assigning a variable to the function without a function name
//arrow functions
const calculateAge = birthYear => 2024 - birthYear;
const myAge = calculateAge(1992);
console.log(myAge);
//what if i want to give more than one parameter in arrow function
const calculateAvg = (sub1,sub2,sub3) =>{
return (sub1+sub2+sub3)/3;
}
const valueOp = calculateAvg(45,48,46);
console.log(valueOp);