-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.js
69 lines (52 loc) · 1.41 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// function sayMyName(){
// console.log("S");
// console.log("A");
// console.log("N");
// console.log("J");
// console.log("H");
// }
// sayMyName; //function reference
// sayMyName(); //function execution
// function add(num1,num2){ //parameters
// // console.log(num1+num2);
// return num1+num2;
// }
// add(2,null) //arguments
// const res=add(2,3);
// console.log(res);
// function loginUserMessage(username="John"){
// if(!username){
// console.log(`Please enter a username..!!`);
// }else{
// return `${username} just logged in`
// }
// }
// const res=loginUserMessage()
// const res=loginUserMessage("Sanjh")
// console.log(res);
// function calculateCartPrice(val1,val2,...num1){
// return num1
// }
// const res=calculateCartPrice(2,4,5,6,8)
// console.log(res);
//--------passed object in function----------
// const user={
// username:"Sanjh",
// prices:199
// }
// function handleObject(anyobject){
// console.log(`Username is ${anyobject.username} and price is ${anyobject.price}`);
// }
// // handleObject(user);
// handleObject({
// username:"John",
// price:199
// })
//--------passed array in function------------
// const arr=[200,400,100,600]
// function returnSecondValue(anyArray){
// return anyArray[1]
// }
// const res=returnSecondValue(arr);
// console.log(res);
// console.log(returnSecondValue([200,300,400,500]))