Topics discussed this week:
• Functions + JSON/Arrays
• Array Manipulations
• JSON
• Map and filter
• Arrow functions
Here you find the readings you have to complete before the sixth lecture.
Deadline Monday
Go through the html-css
, javascript1
and javascript2
Github repositories of one of your fellow students, check if they have neat repository's with the different weeks (eg. week1
, week2
, week3
)of homework for all the modules up and until now. Also check if they have hosted their homework on Github pages. If there is anything that they can improve please provide feedback in an issue.
Deadline Wednesday
-
Say you would like to write a program that doubles the odd numbers in an array and throws away the even number.
Your solution could be something like this:
let numbers = [1, 2, 3, 4]; let newNumbers = []; for(let i = 0; i < numbers.length; i++) { if(numbers[i] % 2 !== 0) { newNumbers.push(numbers[i] * 2); } } console.log("The doubled numbers are", newNumbers); // [2, 6]
Rewrite the above program using
map
andfilter
don't forget to use=>
Underneath you see a very interesting small insight in Maartje's work:
let 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
}
];
let 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
}
];
let tasks = monday.concat(tuesday);
- Write a program that does the following below. Use
map
andfilter
. You will also need aforEach
or afor
loop for the 'summing up' part.
- Collect two days' worth of tasks.
- Convert the task durations to hours, instead of minutes.
- Filter out everything that took two hours or more (remove from the collection)
- Multiply the each duration by a per-hour rate for billing (you can decide yourself what Maartje should make per hour) and sum it all up.
- Output a formatted Euro amount.
- Don't forget to use
=>
Finish up to chapter 7: JSON on roverjs.com!
Deadline Saturday
Deadline Sunday morning
Go trough the reading material in the README.md to prepare for your next class
How to hand in your homework:
• Clone your existing "hyf-javascript2" Github repository.
• Create a new folder "week2" USING THE COMMAND LINE
• Save your homework files inside this folder.
• When you are done with your homework use add/commit and push to upload your homework.
• Write a description for your “commit”.
• Your hyf-javascript2/week2 should now contain all your homework files.
Place the link to your repository folder in Trello.