Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Updated Week1 and Week2 Homework
Adding homework as per new submission style
  • Loading branch information
Catsudemo committed Jul 4, 2019
commit 7cfa2fdb925dbe9d6f8cd1a9cf15707f2be2d9a1
10 changes: 10 additions & 0 deletions Week2/homework/Doublenumbertest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function doubleOddNumbers(numbers) {
// Replace this comment and the next line with your code
numbers.map(v % 2 !== 0 ? v * 2 : v);

console.log(numbers);
}

let totalYears = numbers.reduce(function(accumulator, pilot) {
return accumulator + pilot.years;
}, 0);
6 changes: 6 additions & 0 deletions Week2/homework/doublestuff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const myNumbers = [1, 2, 3, 4];

function doubleOdd(numbers) {
return numbers.map(number => (number % 2 !== 0 ? number * 2 : number));
}
console.log(doubleOdd(myNumbers));
10 changes: 10 additions & 0 deletions Week2/homework/reduce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const array1 = [1, 2, 3, 4];
const reducer = (accumulator, currentValue) => accumulator * currentValue;

// 1 + 2 + 3 + 4
console.log(array1.reduce(reducer, 0));
// expected output: 10

// 5 + 1 + 2 + 3 + 4
console.log(array1.reduce(reducer, 5));
// expected output: 15
71 changes: 71 additions & 0 deletions Week2/homework/timesheet-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
'use strict';

const monday = [
{
name: 'Write a summary HTML/CSS',
duration: 180,
},
{
name: 'Some web development',
duration: 120,
},
{
name: 'Fix homework for class10',
duration: 20,
},
{
name: 'Talk to a lot of people',
duration: 200,
},
];

const tuesday = [
{
name: 'Keep writing summary',
duration: 240,
},
{
name: 'Some more web development',
duration: 180,
},
{
name: 'Staring out the window',
duration: 10,
},
{
name: 'Talk to a lot of people',
duration: 200,
},
{
name: 'Look at application assignments new students',
duration: 40,
},
];

const maartjesTasks = monday.concat(tuesday);
const maartjesHourlyRate = 20;
const reducer = (accumulator, currentValue) => accumulator + currentValue;

function computeEarnings(tasks, hourlyRate) {
const taskCost = tasks
.map(task => task.duration / 60)
.filter(task => task > 2)
.map(task => task * hourlyRate)
.reduce(reducer, 0);
return taskCost.toFixed(2);
}

const taskCost = computeEarnings(maartjesTasks, maartjesHourlyRate);

// eslint-disable-next-line no-unused-vars

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

console.log(`Maartje has earned ${taskCost} euros`);

// Do not change or remove anything below this line
module.exports = {
maartjesTasks,
maartjesHourlyRate,
computeEarnings,
};
30 changes: 16 additions & 14 deletions Week3/homework/step2-2.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
'use strict';

function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) {
const numbers = [];
function makeNumbers {
const numbers = [];
for (let i = startIndex; i <= stopIndex; i++) {
numbers.push(i);
}
}

// Replace this comment and the next line with your code
console.log(startIndex, stopIndex, threeCallback, fiveCallback, numbers);
}

function sayThree(number) {
// Replace this comment and the next line with your code
console.log(number);
}
function sayThree(number) {
const isThree = (numbers = > (number % 3 == 0 ? threeCallback : number))
return isThree

//}

function sayFive(number) {
// Replace this comment and the next line with your code
console.log(number);
function sayFive(number) {
// Replace this comment and the next line with your code
console.log(number);
}
}

threeFive(10, 15, sayThree, sayFive);
//threeFive(10, 15, sayThree, sayFive);

// Do not change or remove anything below this line
module.exports = threeFive;