-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
61 lines (49 loc) · 1.2 KB
/
functions.js
File metadata and controls
61 lines (49 loc) · 1.2 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// function adder(num1, num2) {
// const num3 = num1 + num2
// console.log(num3);
// }
function adder(num1, num2) {
return num3 = num1 + num2
// console.log("sanoj");
}
const result = adder(3, 8)
// console.log(result);
function loginUserMessage(username = 'a'){
if (!username){
// console.log("please user a username?");
return
}
return `${username},just logged in`
}
// console.log(loginUserMessage("sanoj"));
// console.log(loginUserMessage(""));
// console.log(loginUserMessage());
//rest and spread operator
function calculatecartprice(val1 ,val2,...num1){//rest operator
return num1;
}
// console.log(calculatecartprice(200,300,400));
const user = {
name:"sanoj",
price:333,
}
function handleObject (anyObject){
console.log(`username is ${anyObject.name}, price is ${anyObject.price}`);
}
// handleObject(user);
handleObject( {
name:"spiderman",
price:888
})
handleObject({
name:"sanojDD",
price:"priceless"
})
//array
const myArray = [1,3,4,5,6,7]
function returnsecondvalue(getArray){
return getArray[1]
}
// console.log(returnsecondvalue(myArray));
console.log(returnsecondvalue([1,2,3,4,5]));
//scope