-
Notifications
You must be signed in to change notification settings - Fork 33
Week3 #24
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
base: master
Are you sure you want to change the base?
Week3 #24
Changes from all commits
b805713
b757fdd
4c4690d
5263def
40e4ccb
e45c2c1
9ec3cd4
58d7c4a
8a2a4bb
9376435
963fdde
5723d20
bb1baa6
5e575a9
19699c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,65 @@ | ||
'use strict'; | ||
|
||
{ | ||
const bookTitles = [ | ||
// Replace with your own book titles | ||
'harry_potter_chamber_secrets', | ||
]; | ||
'use strict' | ||
const books = [ | ||
{ | ||
title :"Harry Potter Chamber of Secrets", | ||
language:"english", | ||
author:"Joanne K. Rowling", | ||
|
||
// Replace with your own code | ||
console.log(bookTitles); | ||
}, | ||
|
||
{ | ||
title:"Alchemist", | ||
language:"english", | ||
author:"paulo-co", | ||
|
||
}, | ||
|
||
{ | ||
title:"Paula", | ||
language:"english", | ||
author:"isabel allende", | ||
|
||
}, | ||
|
||
{ | ||
|
||
title:"Orlando", | ||
language:"english", | ||
author:"virginia-wolf", | ||
|
||
}, | ||
|
||
{ | ||
title:"Divine Comedy", | ||
language:"English", | ||
author:"dante", | ||
|
||
}, | ||
|
||
{ | ||
title:"The Odyssey", | ||
language: "english", | ||
author:"Homeros", | ||
|
||
}, | ||
|
||
] | ||
|
||
function createAndAppend(parent,typ,attributes={}) { | ||
|
||
const elem = document.createElement(typ) | ||
|
||
parent.appendChild(elem) | ||
|
||
for (const key in attributes) | ||
|
||
elem[key] = attributes[key] | ||
return elem | ||
} | ||
|
||
const ul = createAndAppend(document.body, 'ul', {}) | ||
for (const index in books) { | ||
const book = books[index] | ||
createAndAppend(ul, 'li', {value : index, innerHTML: book.title}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
<!-- replace this with your HTML content --> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title> Book Titles</title> | ||
|
||
</head> | ||
<body> | ||
<script src="app.js"></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
'use strict'; | ||
/*'use strict'; | ||
|
||
function doubleOddNumbers(numbers) { | ||
// Replace this comment and the next line with your code | ||
|
@@ -12,4 +12,29 @@ console.log(doubleOddNumbers(myNumbers)); | |
module.exports = { | ||
myNumbers, | ||
doubleOddNumbers, | ||
}; */ | ||
|
||
'use strict'; | ||
|
||
function doubleOddNumbers(numbers) { | ||
|
||
numbers = numbers.filter(num => num % 2 === 1).map(num => num * 2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice job! But there seems to be many blank lines above and below. Can you delete? |
||
|
||
console.log(numbers); | ||
|
||
return numbers; | ||
|
||
|
||
|
||
const myNumbers = [1, 2, 3, 4]; | ||
|
||
console.log(doubleOddNumbers(myNumbers)); | ||
module.exports = { | ||
|
||
myNumbers, | ||
|
||
doubleOddNumbers, | ||
|
||
}; | ||
|
||
//finished |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange spacing in this file too. Too many blank lines. Needs Prettier formatting. |
||
'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; | ||
|
||
|
||
|
||
function computeEarnings(tasks, hourlyRate) { | ||
|
||
const inHoursArr = tasks.map(task => task.duration / 60).filter(hours => hours <= 2); | ||
|
||
const maartjesPayArr = inHoursArr.map(hours => hours * maartjesHourlyRate); | ||
|
||
const totalPay = maartjesPayArr.reduce((sum, amount) => sum + amount); | ||
|
||
const toEuro = totalPay.toFixed(2); | ||
|
||
return toEuro; | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate); | ||
|
||
|
||
|
||
//converting | ||
|
||
|
||
|
||
console.log(`Martje has earned €${earnings}`); | ||
|
||
|
||
module.exports = { | ||
|
||
maartjesTasks, | ||
|
||
maartjesHourlyRate, | ||
|
||
computeEarnings, | ||
|
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
'use strict'; | ||
|
||
function foo(func) { | ||
// What to do here? | ||
// Replace this comment and the next line with your code | ||
console.log(func); | ||
func(); | ||
} | ||
|
||
function bar() { | ||
console.log('Hello, I am bar!'); | ||
} | ||
|
||
foo(bar); | ||
|
||
// Do not change or remove anything below this line | ||
module.exports = foo; | ||
|
||
//finished |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,43 @@ | ||
'use strict'; | ||
|
||
function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) { | ||
{ | ||
function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) { | ||
|
||
const numbers = []; | ||
for (let i = startIndex; i <= stopIndex; i++) { | ||
|
||
// Replace this comment and the next line with your code | ||
console.log(startIndex, stopIndex, threeCallback, fiveCallback, numbers); | ||
} | ||
numbers.push(i); | ||
|
||
//A callback to call if the number is divisible by 3 | ||
|
||
if (i % 3 === 0) { | ||
|
||
threeCallback(i); | ||
|
||
} | ||
|
||
//A callback by 5 | ||
|
||
if (i % 5 === 0) { | ||
|
||
fiveCallback(i); | ||
|
||
}}} | ||
|
||
|
||
threeFive() | ||
|
||
function sayThree(number) { | ||
// Replace this comment and the next line with your code | ||
console.log(number); | ||
console.log(number, 'value is divisible by 3'); | ||
} | ||
|
||
|
||
|
||
function sayFive(number) { | ||
// Replace this comment and the next line with your code | ||
console.log(number); | ||
console.log(number, 'value is divisible by 5'); | ||
} | ||
|
||
threeFive(10, 15, sayThree, sayFive); | ||
|
||
// Do not change or remove anything below this line | ||
module.exports = threeFive; | ||
|
||
} | ||
//finished |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like an extra space here. In fact, I think there looks like to be lots of strange spacing. Can you run prettier on your files so they fix the formatting issues?