Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .gitignore
Binary file not shown.
9 changes: 9 additions & 0 deletions .test-summary/TEST_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Test Summary

**Mentors**: For more information on how to review homework assignments, please refer to the [Review Guide](https://github.com/HackYourFuture/mentors/blob/main/assignment-support/review-guide.md).

### 2-Browsers - Week1

| Exercise | Passed | Failed | ESLint |
|--------------|--------|--------|--------|
| ex1-bookList | 6 | - | ✓ |
20 changes: 19 additions & 1 deletion 2-Browsers/Week1/assignment/ex1-bookList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,27 @@ https://hackyourfuture.github.io/example-pages/Browsers/Week1/1-booklist/
//cspell: enable

function createBookList(books) {
// TODO your code goes in here, return the ul element
const ul = document.createElement ('ul');
books.forEach( book => {
const li = document.createElement ('li');
const p = document.createElement ( 'p');
p.textContent = `${book.title} - ${book.author} `;
const img = document.createElement ('img');
img.src = `https://covers.openlibrary.org/b/isbn/${book.isbn}-M.jpg`;
img.alt = `${book.title} cover`;
li.appendChild (p);
li.appendChild (img);
if (book.alreadyRead) {
li.style.backgroundColor = 'green';
}
else
{ li.style.backgroundColor = 'red'} ;
ul.appendChild (li);
});
return ul;
Comment on lines +21 to +38

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

}


function main() {
const myBooks = [
{
Expand Down
36 changes: 36 additions & 0 deletions 2-Browsers/Week1/assignment/ex1-bookList/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
/* Write your style here */
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
}
h1 {
text-align: center;
color: #333;
}
ul {
list-style-type: none;
padding: 0;
display : grid ;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap : 16px;

}
li {
background: #fff;
margin: 10px 0;
padding: 15px;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
img {
width: 100% ;
height: auto ;
border -radius: 5px ;
display : block ;

}
p {
margin: 0;
padding: 0;
}
Comment on lines +2 to +37

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

14 changes: 13 additions & 1 deletion 2-Browsers/Week1/assignment/ex2-aboutMe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,16 @@ Full description at: https://github.com/HackYourFuture/Assignments/tree/main/2-B
3. Look in the css file!
------------------------------------------------------------------------------*/

// TODO add your JavaScript code here.
function aboutMe() {
const nickname = document.querySelector ('#nickname');
nickname.textContent = 'Rim';
const favFood = document.querySelector ('#fav-food');
favFood.textContent = 'Sushi';
const hometown = document.querySelector ('#hometown');
hometown.textContent = 'Tokyo';
const listItems = document.querySelectorAll ('li');
listItems.forEach(item => {
item.classList.add('list-item');
});
}
aboutMe();
Comment on lines +11 to +23

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

12 changes: 11 additions & 1 deletion 2-Browsers/Week1/assignment/ex2-aboutMe/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
/* 3. Add a css rule for .list-item to make the color red. */

body {

font-family: Arial, sans-serif;
margin: auto;
padding: 20px;
}

.list-item {
color: red ;
}
Comment on lines +1 to +11

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

5 changes: 4 additions & 1 deletion 2-Browsers/Week1/assignment/ex3-hijackLogo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ Full description at: https://github.com/HackYourFuture/Assignments/tree/main/2-B
HackYourFuture logo instead.
------------------------------------------------------------------------------*/
function hijackGoogleLogo() {
// TODO your code goes in here
const logo = document.querySelector('img[alt="Google"]') ;
logo.src = 'https://www.hackyourfuture.be/static/logo.png';
logo.srcset = 'https://www.hackyourfuture.be/static/logo.png';

Comment on lines +10 to +13

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good!

}

hijackGoogleLogo();
7 changes: 4 additions & 3 deletions 2-Browsers/Week1/assignment/ex4-whatsTheTime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Full description at: https://github.com/HackYourFuture/Assignments/tree/main/2-B
2. Have the function execute when it's loading in the browser.
------------------------------------------------------------------------------*/
function addCurrentTime() {
// TODO complete this function
}
document.querySelector('time').textContent= new Date().toLocaleTimeString() ;
setInterval(addCurrentTime, 1000) ;
Comment on lines +10 to +11

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Almost there, but not quite.
Hint:
Where on the document do you want to display the time? header? body? etc.


// TODO execute `addCurrentTime` when the browser has completed loading the page
}
window.onload = addCurrentTime;
44 changes: 39 additions & 5 deletions 2-Browsers/Week1/assignment/ex5-catWalk/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,43 @@ Full description at: https://github.com/HackYourFuture/Assignments/tree/main/2-B
Dancing cat URL:

https://media1.tenor.com/images/2de63e950fb254920054f9bd081e8157/tenor.gif
-----------------------------------------------------------------------------*/
function catWalk() {
// TODO complete this function
}
-----------------------------------------------------------------------------*/
window.addEventListener('load', function () {
const cat = document.querySelector('img');
const originalSrc = cat.src || 'http://www.anniemation.com/clip_art/images/cat-walk.gif';
const danceSrc = 'https://media1.tenor.com/images/2de63e950fb254920054f9bd081e8157/tenor.gif';

cat.style.position = 'absolute';
cat.style.left = '0px';

let hasDanced = false;
let walkTimer = null;

function catWalk() {
const x = parseInt(cat.style.left, 10) || 0;
const rightEdge = window.innerWidth - cat.width;
const mid = rightEdge / 2;

if (x >= rightEdge) {
cat.style.left = '0px';
hasDanced = false;
return;
}

if (!hasDanced && x >= mid) {
hasDanced = true;
clearInterval(walkTimer);
cat.src = danceSrc;
setTimeout(function () {
cat.src = originalSrc;
walkTimer = setInterval(catWalk, 50);
}, 5000);
return;
}

cat.style.left = (x + 10) + 'px';
}

walkTimer = setInterval(catWalk, 50);
});
Comment on lines +23 to +60

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Good effort but not quite there yet. I see the cat walking in place. It doesn't meet the requirements of walking across the screen from left to right and doing a dance for 50ms in the middle of the screen.


// TODO execute `catWalk` when the browser has completed loading the page