Skip to content

Commit 1d7ea1f

Browse files
committed
Add existing file
1 parent 7a0867a commit 1d7ea1f

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

Week2/homework/maartjes_work.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,31 @@ const tuesday = [
4545
const tasks = monday.concat(tuesday);
4646

4747
// Add your code here
48+
49+
//map the durations
50+
const durations = tasks.map(task => task.duration++);
51+
console.log(durations);
52+
53+
//filter out less than 120 (2 hours)
54+
const moreThan2Hrs = durations.filter(number => {
55+
return number > 120
56+
});
57+
console.log(moreThan2Hrs);
58+
59+
// multiply each duration by a per hour rate and sum them all up
60+
// 12.25 is rate per hour
61+
62+
const finalSum = moreThan2Hrs.map (number => number*12.25).reduce((acc, currValue)=> {
63+
return acc + currValue;
64+
}, 0);
65+
console.log(finalSum);
66+
67+
//if currency was in SEK:
68+
let kronor = Number(12250).toLocaleString("en-SEK", {minimumFractionDigits: 2});
69+
console.log("SEK " + kronor);
70+
71+
//if currency was in EURO:
72+
let euro = Number(12250).toLocaleString("en-EUR", {minimumFractionDigits: 2});
73+
console.log("€ " + euro);
74+
75+

Week2/homework/map_filter.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,15 @@
22

33
const numbers = [1, 2, 3, 4];
44

5-
// Add your code here
5+
//question 2.1
6+
7+
const newNumbers = numbers.filter(number => number% 2 !==0) .map(number => number*2);
8+
console.log(newNumbers);
9+
10+
/* without arrow function
11+
const nnewNumbers = numbers.filter(function(number){
12+
return (number% 2 !== 0);
13+
}).map(function(number){
14+
return number * 2;
15+
});
16+
console.log(nnewNumbers); */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy