-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_02.js
More file actions
43 lines (32 loc) · 988 Bytes
/
Copy pathtask_02.js
File metadata and controls
43 lines (32 loc) · 988 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
36
37
38
39
40
41
42
43
// SHOPPING CART
function shoppingCart(...price) {
let sum = 0;
for (let index = 0; index<=2; index++) {
sum = sum + price[index];
}
console.log(sum);
return price;
}
console.log(shoppingCart(25, 35, 50));
//IMPORTANT NOTE DETERMINING THE VALUE OF PRICE IN THE BELOW STATEMENT
function shoppingCart(num1, num2, ...price) {
return price;
}
console.log(shoppingCart(25, 35, 50, 100));
//OBJECT HANDLING
const studentDetails={
name : "pratham",
batch : "1A52",
};
// USED THE BELOW STEP TO REFER NAME JUST BY NAME AND NOT BY STUDENTDETAILS.NAME AND SIMILAR FOR BATCH JUST FOR CONVINIENCE
const {name} = studentDetails;
const {batch} = studentDetails;
function objectHandling(object_Name){
console.log(`My name is ${name} and batch is ${batch}.`);
}
objectHandling(studentDetails)
const myNewArray = [200, 400, 100, 600]
function arrayHandling(anyArray){
console.log(`second value is: ${anyArray[1]}`)
}
arrayHandling(myNewArray)