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

Skip to content

Commit 6a0512c

Browse files
committed
week2 structure
1 parent e2e658f commit 6a0512c

File tree

9 files changed

+168
-2
lines changed

9 files changed

+168
-2
lines changed

Week2/MAKEME.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Before we head into the exercises, it might be nice to do some interactive exerc
1515

1616
## **2. JavaScript exercises**
1717

18-
> Inside of your `JavaScript2` fork, create a folder called `week2`. Inside of that folder, create a folder called `js-exercises`. For all the following exercises create a new `.js` file in that folder (5 files in total). Make sure the name of each file reflects its content: for example, the filename for exercise one could be `oddOnesOut.js`.
18+
> Inside of your `JavaScript2` fork, find the folder called `Week2`. Inside of that folder, find the folder called `js-exercises`. In this folder you will find five `.js` files, one for each exercise where you need to write your code. Please use the correct file for the respective exercise.
1919
2020
**Exercise 1: The odd ones out**
2121

@@ -137,7 +137,7 @@ Programming can be used to not only make websites, but also games! In the follow
137137

138138
> Every week ends with a project you have to build on your own. Instead of getting clear-cut instructions, you'll get a list of criteria that your project needs to measure up to.
139139
140-
> Before you start, create a new folder called `project` that includes the files for the following app you'll be building.
140+
> Write the project code in the folder `Week3 \ project`.
141141
142142
In this week's project you'll be making a Pomodoro Clock! A user can specify how many minutes the timer should be set, and with a click on the play button it starts counting down! If the user wants to pause the timer, they can do so by clicking the pause button.
143143

Week2/js-exercises/ex1-oddOnesOut.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
3+
** Exercise 1: The odd ones out **
4+
5+
Rewrite the following function using map and filter.
6+
Avoid using for loop or forEach.
7+
The function should still behave the same.
8+
9+
*/
10+
function doubleEvenNumbers(numbers) {
11+
const newNumbers = [];
12+
for (let i = 0; i < numbers.length; i++) {
13+
if (numbers[i] % 2 === 0) {
14+
newNumbers.push(numbers[i] * 2);
15+
}
16+
}
17+
return newNumbers;
18+
}
19+
20+
const myNumbers = [1, 2, 3, 4];
21+
console.log(doubleEvenNumbers(myNumbers)); // Logs "[4, 8]" to the console
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
3+
** Exercise 2: What 's your Monday worth? **
4+
5+
Write a function that finds out what your hourly rate on a Monday would be
6+
Use the map array function to take out the duration time for each task.
7+
Avoid using for loop or forEach.
8+
Multiply each duration by a per - hour rate for billing and sum it all up.
9+
Output a formatted Euro amount, rounded to Euro cents, e.g: €11.34.
10+
Make sure the function can be used on any array of objects that contain a duration property with a number value
11+
12+
*/
13+
14+
15+
function dayWorth(tasks, hourlyRate) {
16+
// put your code in here, the function does returns a euro formatted string
17+
}
18+
19+
const mondayTasks = [{
20+
name: 'Daily standup',
21+
duration: 30, // specified in minutes
22+
},
23+
{
24+
name: 'Feature discussion',
25+
duration: 120,
26+
},
27+
{
28+
name: 'Development time',
29+
duration: 240,
30+
},
31+
{
32+
name: 'Talk to different members from the product team',
33+
duration: 60,
34+
},
35+
];
36+
37+
console.log(dayWorth(mondayTasks, 25))
38+
console.log(dayWorth(mondayTasks, 13.37))
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
3+
** Exercise 3: Lemon allergy **
4+
5+
Your mom bought you a basket of fruit, because you 're doing so well in HackYourFuture. How sweet of her!
6+
However, she forgot that you are allergic to lemons!Let 's quickly dispose of them before you get an attack.
7+
8+
Write a function that uses the filter array function to take out the lemons.
9+
Avoid using for loop or forEach.
10+
Output a string that says: "My mom bought me a fruit basket, containing [array of fruits] !"
11+
12+
*/
13+
14+
15+
function takeOutLemons(basket) {
16+
// your code goes in here. The output is a string
17+
}
18+
19+
const fruitBasket = ['Apple', 'Lemon', 'Grapefruit', 'Lemon', 'Banana', 'Watermelon', 'Lemon'];
20+
21+
console.log(takeOutLemons(fruitBasket));
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
3+
** Exercise 4: Collective age **
4+
5+
Have you ever wondered how old the HackYourFuture team members are ? Or better yet : what the collective age is ? Let 's find out!
6+
7+
Write a function that calculates the combined age of every member
8+
Avoid using for loop or forEach.
9+
*/
10+
11+
function collectiveAge(people) {
12+
// return the sum of age for all the people
13+
}
14+
15+
const hackYourFutureMembers = [{
16+
name: 'Wouter',
17+
age: 33
18+
},
19+
{
20+
name: 'Federico',
21+
age: 32
22+
},
23+
{
24+
name: 'Noer',
25+
age: 27
26+
},
27+
{
28+
name: 'Tjebbe',
29+
age: 22
30+
},
31+
];
32+
33+
console.log("The collective age of the HYF team is: " + collectiveMembers(hackYourFutureMembers));
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<html>
2+
3+
<!-- your html code goes in here -->
4+
5+
</html>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
3+
** Exercise 5: My favorite hobbies **
4+
5+
Write a program that outputs each of these inside an HTML file
6+
Create an HTML and JavaScript file, link them together
7+
Use the map and / or forEach function to put each hobby into a list item
8+
Put the list items in an unordered list
9+
*/
10+
11+
function createHTMLList(arr) {
12+
// your code goes in here
13+
}
14+
15+
const myHobbies = [
16+
'Meditation',
17+
'Reading',
18+
'Programming',
19+
'Hanging out with friends',
20+
'Going to the gym',
21+
];

Week2/project/index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Pomodoro Clock</title>
8+
</head>
9+
10+
<body>
11+
<div id="app">
12+
13+
</div>
14+
<script src="index.js"></script>
15+
</body>
16+
17+
</html>

Week2/project/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
In this week 's project you'll be making a Pomodoro Clock!
3+
A user can specify how many minutes the timer should be set, and with a click on the play button it starts counting down!If the user wants to pause the timer, they can do so by clicking the pause button.
4+
5+
If the timer is running, the user can 't change the session length anymore
6+
Use at least 3 functions
7+
Display minutes and seconds
8+
If the timer finishes the timer should be replaced by the message: Time 's up!
9+
*
10+
*/

0 commit comments

Comments
 (0)