-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment 2-2
More file actions
66 lines (39 loc) · 1.1 KB
/
Copy pathAssignment 2-2
File metadata and controls
66 lines (39 loc) · 1.1 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
62
63
64
65
const friends = ["michel", "jane", "philip", "mark"]
friends.push("pasindu")
console.log(friends)
const newLength = friends.push("thiwanka")
console.log(friends)
console.log(newLength)
friends.unshift("John")
console.log(friends)
const popped = friends.pop()
console.log(friends)
console.log(popped)
friends.pop()
console.log(friends)
friends.shift()
console.log(friends)
console.log(friends.indexOf("jane"))
console.log(friends.indexOf("mark"))
console.log(friends.indexOf("bob"))
console.log(friends.includes("cena"))
console.log(friends.includes("jane"))
if (friends.includes("jane")) {
console.log("you have a friend")
} else {
console.log("you does not have friend")
}
function calcTip(billValue) {
if (50 <= billValue <= 300) {
return billValue * 0.15
}
else {
return billValue * 0.2
}
}
console.log(calcTip(100))
const bills = [125, 555, 44]
const tips = [calcTip(bills[0]), calcTip(bills[1]), calcTip(bills[2])]
console.log(tips)
const total = [bills[0] + calcTip(bills[0]), bills[1] + calcTip(bills[1]), bills[2] + calcTip(bills[2])]
console.log(total)