-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathfunctions.js
More file actions
39 lines (30 loc) · 1.13 KB
/
functions.js
File metadata and controls
39 lines (30 loc) · 1.13 KB
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
//Declaring a function
function myFunction(){
console.log("Hello this is my function being called :)");
}
//Calling a funtion
myFunction();
//------------Function Parameters---------------
//Function Parameters (simple)
function simpleFunction(message){
console.log(message);//prints simple message
}
simpleFunction("This is my message");
//Funtion Parameter (multiple)
function phoneDirectory(name, phno){
console.log(name);//prints the name passed
console.log(phno);//prints the phone no passed
}
phoneDirectory("Kaiwalya Koparkar",5674894383);
//Undefined Parmeter password
function missMatchDir(name, phno){
console.log(name);//prints the name passed
console.log(phno);//prints 'undefined' because it's not passed
}
missMatchDir("Kaiwalya");//Not passing the phone number although it is required by the function
//Default value if the parameter is not passed or if it is undefined
function defPara(userName="username: user1234"){
console.log(userName);//if passed then prints the passed value (username: Kaiwalya) other vise prints the default value (username: user1234)
}
defPara("username: Kaiwalya");
defPara();