-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
35 lines (29 loc) · 784 Bytes
/
functions.js
File metadata and controls
35 lines (29 loc) · 784 Bytes
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
// declation of a function
// This function can be defined any where in the file and used anywhere
function greet(){
console.log('Good morning');
}
// call it using
greet();
// writing a function expresssion
// This function will only work after defining it
const speak = function(){
console.log('Hey there !')
}; // we use a semicolon to define it
// call it using
speak();
// Arguments and parameteres
const say = function(time = 'morning' , name = 'Anonymous') // These are the default values
{
console.log(`Good ${time} ${name}`);
};
say();
say('night','shaun');
say('evening');
console.log('Returning values');
// returning values
const calcArea = function(radius){
return 3.14 * radius **2;
}
let area = calcArea(10);
console.log('The area is ',area);