Skip to content

Commit 76fe8dc

Browse files
author
Reem-Elfalah
committed
Exercises file
1 parent e191104 commit 76fe8dc

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

prepExercises.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*Basic Requirments
2+
//0.Preparation
3+
4+
Download the link & Complete the project mentioned in the slides:
5+
https://docs.google.com/uc?authuser=0&id=0B_KMvJgAi82ERmhqd1RYdTdHUXc&export=download
6+
\ ----------Instructions----------\
7+
1. Start a new project for today by downloading this link: https://github.com/yanarchy/rbk-basic/archive/each-dom.zip to your Desktop (or somewhere else). Don't forget to rename the folder to something meaningful!
8+
2. Work on the following with your partner.
9+
1.Look at the index.html file and discuss with a partner what the different HTML elements do. Please try to answer the following WITHOUT instructors. Please use Google or look through the previous exercises.
10+
11+
a. What does class mean? What is it used for?
12+
b. What does id mean? What is it used for?
13+
c. What is the difference between them?
14+
d. How do you think they may be useful?
15+
2. Try the following in your console:
16+
17+
document.getElementsByTagName('div');
18+
document.getElementsByClassName('box');
19+
document.getElementById('list');
20+
3. What do they return?
21+
22+
4. Write a function called each that takes in an array and a callback. Each should loop through the array and pass each item in the array through the callback.
23+
24+
function each (arr, callback) {
25+
// TODO: Your code here
26+
}
27+
5. Using your each, please add 'Hello World' to each of the divs with a class of 'box'. This should be written in your main.js file.
28+
29+
function each (arr, callback) {
30+
// TODO: Your code here
31+
}
32+
Hint: You may want to look at .textContent
33+
6. I need the picture to be smaller. Please give the picture a height of '300px'
34+
35+
7. Using your each function, please change all of the li elements to use the below data:
36+
37+
var cities = ['San Francisco', 'Cairo', 'Tokyo', 'Nairobi'];
38+
Thus, when you are done, you should have this on your page:
39+
tSan Francisco
40+
Cairo
41+
Tokyo
42+
Nairobi
43+
8. Bonus Challenge: Using ONLY JavaScript, please change the current image to something else (you decide!).
44+
*/

0 commit comments

Comments
 (0)