This repository was archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 327
Homework week2 #30
Closed
Closed
Homework week2 #30
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,138 @@ | ||
| 'use strict'; | ||
| { | ||
| const bookTitles = [ | ||
| // Replace with your own book titles | ||
| 'harry_potter_chamber_secrets' | ||
| 'a_game_of_thrones', | ||
| 'a_clash_of_kings', | ||
| 'a_storm_of_swords', | ||
| 'a_feast_of_crows', | ||
| 'a_dance_with_dragons', | ||
| 'harry_potter_chamber_secrets', | ||
| 'harry_potter_prisoner_azkaban', | ||
| 'harry_potter_goblet_fire', | ||
| 'harry_potter_order_phoenix', | ||
| 'harry_potter_deathly_hallows' | ||
| ]; | ||
|
|
||
| const booksInfo = { | ||
| a_game_of_thrones: { | ||
| title: 'A Song of Ice and Fire - A Game of Thrones', | ||
| language: 'English', | ||
| author: 'George R.R. Martin', | ||
| pages: '694', | ||
| }, | ||
|
|
||
| // Replace with your own code | ||
| console.log(bookTitles); | ||
| a_clash_of_kings: { | ||
| title: 'A Song of Ice and Fire - A Clash of Kings', | ||
| language: 'English', | ||
| author: 'George R.R. Martin', | ||
| pages: '768', | ||
| }, | ||
| a_storm_of_swords: { | ||
| title: 'A Song of Ice and Fire - A Storm of Swords', | ||
| language: 'English', | ||
| author: 'George R.R. Martin', | ||
| pages: '973', | ||
| }, | ||
| a_feast_of_crows: { | ||
| title: 'A Song of Ice and Fire - A Feast of crows', | ||
| language: 'English', | ||
| author: 'George R.R. Martin', | ||
| pages: '753', | ||
| }, | ||
| a_dance_with_dragons: { | ||
| title: 'A Song of Ice and Fire - A Dance with Dragons', | ||
| language: 'English', | ||
| author: 'George R.R. Martin', | ||
| pages: '1040', | ||
| }, | ||
| harry_potter_chamber_secrets: { | ||
| title: 'Harry Potter and the Chamber of Secrets', | ||
| language: 'English', | ||
| author: 'J. K. Rowling', | ||
| pages: '251', | ||
| }, | ||
| harry_potter_prisoner_azkaban: { | ||
| title: 'Harry Potter and the Prisoner of Azkaban', | ||
| language: 'English', | ||
| author: 'J. K. Rowling', | ||
| pages: '317', | ||
| }, | ||
| harry_potter_goblet_fire: { | ||
| title: 'Harry Potter and the Goblet of Fire', | ||
| language: 'English', | ||
| author: 'J. K. Rowling', | ||
| pages: '636', | ||
| }, | ||
| harry_potter_order_phoenix: { | ||
| title: 'Harry Potter and the Order of the Phoenix', | ||
| language: 'English', | ||
| author: 'J. K. Rowling', | ||
| pages: '766', | ||
| }, | ||
| harry_potter_deathly_hallows: { | ||
| title: 'Harry Potter and the Deathly Hallows', | ||
| language: 'English', | ||
| author: 'J. K. Rowling', | ||
| pages: '694', | ||
| } | ||
| }; | ||
|
|
||
| function main() { | ||
| const container = document.getElementById('myBooks'); | ||
| const Header = document.createElement('h1'); | ||
| Header.innerHTML = 'My Top 10 Books'; | ||
| container.appendChild(Header); | ||
|
|
||
| const booksList = document.createElement('ul'); | ||
| container.appendChild(booksList); | ||
|
|
||
| for (const i in booksInfo) { | ||
| const li = document.createElement('li'); | ||
| booksList.appendChild(li); | ||
| li.setAttribute("id", [i]); | ||
|
|
||
| const title = document.createElement('h2'); | ||
| li.appendChild(title); | ||
| title.innerHTML = booksInfo[i].title; | ||
|
|
||
| const language = document.createElement('p'); | ||
| li.appendChild(language); | ||
| language.innerHTML = 'Language: ' + booksInfo[i].language; | ||
|
|
||
| const author = document.createElement('p'); | ||
| li.appendChild(author); | ||
| author.innerHTML = 'Author: ' + booksInfo[i].author; | ||
|
|
||
| const pages = document.createElement('p'); | ||
| li.appendChild(pages); | ||
| pages.innerHTML = 'Pages: ' + booksInfo[i].pages; | ||
| } | ||
|
|
||
|
|
||
| const images = { | ||
| a_game_of_thrones: './img/a_game_of_Thrones.jpg', | ||
| a_clash_of_kings: './img/a_clash_of_kings.jpg', | ||
| a_storm_of_swords: './img/a_storm_of_swords.jpg', | ||
| a_feast_of_crows: './img/a_feast_of_crows.jpg', | ||
| a_dance_with_dragons: './img/a_dance_with_dragons.jpg', | ||
| harry_potter_chamber_secrets: './img/harry_potter_chamber_secrets.jpeg', | ||
| harry_potter_prisoner_azkaban: './img/harry_potter_prisoner_azkaban.jpg', | ||
| harry_potter_goblet_fire: './img/harry_potter_goblet_fire.jpg', | ||
| harry_potter_order_phoenix: './img/harry_potter_order_phoenix.jpeg', | ||
| harry_potter_deathly_hallows: './img/harry_potter_deathly_hallows.jpg' | ||
| }; | ||
|
|
||
| for (const key in images) { | ||
| const img = document.createElement('img'); | ||
| img.setAttribute('src', images[key]); | ||
| img.setAttribute('alt', key); | ||
|
|
||
| const imgList = document.createElement('li'); | ||
| imgList.appendChild(img); | ||
|
|
||
| const x = document.getElementById(key); | ||
| x.appendChild(imgList); | ||
| } | ||
| } | ||
| window.addEventListener('load', main); | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,15 @@ | ||
| <!-- replace this with your HTML content --> | ||
| <!DOCTYPE html> | ||
| <html> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <link rel="stylesheet" type="text/css" media="screen" href="style.css" /> | ||
| <title></title> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div id="myBooks"></div> | ||
| <script type="text/javascript" src="app.js"></script> | ||
| </body> | ||
|
|
||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,16 @@ | ||
| /* add your styling here */ | ||
| *{ | ||
| list-style-type: none; | ||
| } | ||
|
|
||
| img{ | ||
| width: 200px; | ||
| border: 2px solid black | ||
| } | ||
|
|
||
| h1, h2, p{ | ||
| font-family: "tahoma"; | ||
| } | ||
|
|
||
| #myBooks { | ||
| text-align: center; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,3 +45,10 @@ const tuesday = [ | |
| const tasks = monday.concat(tuesday); | ||
|
|
||
| // Add your code here | ||
| const salary = tasks | ||
| .map((task) => (task.duration / 60)) | ||
| .filter((duration) => duration >= 2) | ||
| .map((duration) => duration * 23) | ||
| .reduce((acc, current) => acc + current); | ||
|
|
||
| console.log('Maartje has earned €' + salary.toFixed(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. I personaly would move the .toFixed(2) to the function 'salary' 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. you could consider to pass the tasks and salary as two arguments, something like: const calculateEarnings = (arrayOfTasks, hourlyWage) => |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
you could consider making the function more descriptive e.g. calculateSalary