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

Skip to content

Commit f9624bd

Browse files
committed
Update homework
1 parent 992f32e commit f9624bd

File tree

9 files changed

+100
-2
lines changed

9 files changed

+100
-2
lines changed
81.3 KB
Loading
105 KB
Loading

javascript2/week3/assets/carbon.svg

Lines changed: 22 additions & 0 deletions
Loading
248 KB
Loading
93 KB
Loading

javascript2/week3/assets/planet-log.svg

Lines changed: 32 additions & 0 deletions
Loading
96.8 KB
Loading

javascript2/week3/assets/run-after-delay.svg

Lines changed: 22 additions & 0 deletions
Loading

javascript2/week3/homework.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,36 @@ We want you to realise that **functions are just variables** in javascript. It i
99
The warmup is a **little abstract**, it will get more concrete later on!
1010

1111
1. Log out the text `Called after 2.5 seconds` 2.5 seconds after the script is loaded.
12+
13+
1214
2. Create a function that takes 2 parameters: `delay` and `stringToLog`. Calling this function should log out the `stringToLog` after `delay` seconds. Call the function you have created with some different arguments.
13-
3. Create a button in html. When clicking this button, use the function you created in the previous task to log out the text: `3.5 seconds after button is clicked` 3.5 seconds after the button is clicked.
15+
![second task](assets/carbon.png)
16+
17+
1. Create a button in html. When clicking this button, use the function you created in the previous task to log out the text: `Called after 5 seconds` 5 seconds after the button is clicked.
18+
19+
![second task](assets/button-delay.gif)
20+
1421
4. Create two functions and assign them to two different variables. One function logs out `Earth`, the other function logs out `Saturn`. Now create a new third function that has one parameter: `planetLogFunction`. The only thing the third function should do is call the provided parameter function. Try call the third function once with the `Earth` function and once with the `Saturn` function.
22+
23+
![second task](assets/planet-log.png)
24+
1525
5. Create a button with the text called "Log location". When this button is clicked the location (latitude, longitude) of the user should be logged out using this [browser api](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API)
26+
27+
![second task](assets/log-location.gif)
28+
29+
1630
6. *Optional* Now show that location on a map using fx the [Google maps api]( https://developers.google.com/maps/documentation/javascript/tutorial)
31+
32+
1733
7. Create a function called `runAfterDelay`. It has two parameters: `delay` and `callback`. When called the function should wait `delay` seconds and then call the provided callback function. Try and call this function with different delays and different callback functions
34+
35+
![second task](assets/run-after-delay.png)
36+
1837
8. Check if we have double clicked on the page. A double click is defined by two clicks within 0.5 seconds. If a double click has been detected, log out the text: "double click!"
19-
9. Create a function called `jokeCreator` that has three parameters: `shouldTellFunnyJoke` - boolean, `logFunnyJoke` - function and `logBadJoke` - function. If you set `tellFunnyJoke` to `true` it should call the `logFunnyJoke` function that should log out a funny joke. And vice versa.
38+
39+
40+
41+
9. Create a function called `jokeCreator` that has three parameters: `shouldTellFunnyJoke` - boolean, `logFunnyJoke` - function and `logBadJoke` - function. If you set `tellFunnyJoke` to `true` it should call the `logFunnyJoke` function that should log out a funny joke. And vice versa.
2042

2143
### Function as a variable
2244
Create funtions that are used in these different ways:

0 commit comments

Comments
 (0)