-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
63 lines (46 loc) · 1.08 KB
/
functions.js
File metadata and controls
63 lines (46 loc) · 1.08 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
function getEvenNumbers(array) {
let evenNumbers = [];
for (let index = 0; index < array.length; index++) {
if (array[index] % 2 === 0) {
evenNumbers.push(array[index]);
}
}
return evenNumbers;
// return array.filter(num => num % 2 === 0);
}
const createCounter = function() {
let count = 0;
return {
getCount:()=> {
return count;
},
increment:() => {
count++;
return count;
},
decrement:() => {
count--;
return count;
},
reset:() => {
count = 0;
return count;
}
}
}
function priceOfPizza(obj) {
let sum = 0;
const prices = {
"pepperoni": 3000,
"veggie": 5000,
"chicken suya": 1000
};
for (let key in obj) {
if (prices[key]) {
sum += prices[key] * obj[key];
}
}
console.log("Total price of pizza:", sum);
return sum;
}
module.exports = {getEvenNumbers, createCounter, priceOfPizza};