Thanks to visit codestin.com
Credit goes to github.com

Skip to content

week2 js completed #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Week2/homework/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"squirtle"
]
}
13 changes: 13 additions & 0 deletions Week2/homework/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Pokemon Sprites</title>
</head>
<body>
<h2>Pokemon Sprites</h2>
<script type="text/javascript" src="squirtle-sprites.js"></script>
</body>
</html>
14 changes: 11 additions & 3 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,25 @@ const tuesday = [
const maartjesTasks = monday.concat(tuesday);
const maartjesHourlyRate = 20;

/**
* Use of High order functions: map, filter, toFixed
*/

function computeEarnings(tasks, hourlyRate) {
// Replace this comment and the next line with your code
console.log(tasks, hourlyRate);
// mapping duration of tasks from minutes to hours and filtering out duties < 2h
const timeInHours = tasks.map(time => time.duration / 60).filter(duty => duty >= 2);
const salaryPerDay = timeInHours.map(hoursPerDay => hoursPerDay * hourlyRate);
const totalSalary = salaryPerDay.reduce((sum, dailySalary) => sum + dailySalary, 0);
const euroSalary = totalSalary.toFixed(2);
return euroSalary;
}

// eslint-disable-next-line no-unused-vars
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);

// add code to convert `earnings` to a string rounded to two decimals (euro cents)

console.log(`Maartje has earned €${'replace this string with the earnings rounded to euro cents'}`);
console.log(`Maartje has earned €${earnings}`);

// Do not change or remove anything below this line
module.exports = {
Expand Down
8 changes: 6 additions & 2 deletions Week2/homework/map-filter.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
'use strict';

function doubleOddNumbers(numbers) {
// Replace this comment and the next line with your code
// the following iterates the variables in numbers(with filter) and checking if they´re divisible by 2
// const newNumbers = [];
// for (let i = 0; i =numbers.length)
numbers = numbers.filter(num => num % 2 === 1).map(num => num * 2);
console.log(numbers);
return numbers;
}

const myNumbers = [1, 2, 3, 4];
console.log(doubleOddNumbers(myNumbers));
console.log(doubleOddNumbers(myNumbers)); // output : [2, 6]

// Do not change or remove anything below this line
module.exports = {
Expand Down
7 changes: 7 additions & 0 deletions Week2/homework/squirtle-sprites.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.