Skip to content

Nikita-w1-Browsers #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

NStefanchuk
Copy link

No description provided.

@RHSebregts RHSebregts self-requested a review March 25, 2025 08:02
@RHSebregts RHSebregts self-assigned this Mar 25, 2025
Copy link

@RHSebregts RHSebregts left a comment

Choose a reason for hiding this comment

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

I think you did pretty well on the assignment. The cat is moving, but could still use some love.
If I'm being completely honest, the clock/date function being in British time has a bit of an AI smell to it. If my hunch there is correct, that is fine, but I think it'd be good to properly check and understand each line when you do use it.

const listBooks = document.createElement('ul');
listBooks.classList.add('list__books');

for (let i = 0; i < books.length; i++) {

Choose a reason for hiding this comment

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

I like the idea of a loop here, but I think we could also use a different kind of loop to go through all the elements in the array.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

itemBook.classList.add('item__book');

if (books[i].alreadyRead) {
itemBook.classList.add('item__book-read');

Choose a reason for hiding this comment

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

I'm personally not a big fan of this casing. I would love to see a more conventional one, like kebab, camel, or snake.

Choose a reason for hiding this comment

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

Ok, ignore that, apparently this is very common for BEM, which I'm not super familiar with. So I guess I stand corrected!

Copy link
Author

Choose a reason for hiding this comment

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

okey, thanks! I use it a lot
But I will try kebab later

const itemBook = document.createElement('li');
itemBook.classList.add('item__book');

if (books[i].alreadyRead) {

Choose a reason for hiding this comment

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

I think this could be a great place to use a ternary operator on the DOM element.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

imgBook.src = books[i].bookUrl;
imgBook.alt = `Cover of ${books[i].title} by ${books[i].author}`;

paragraph.textContent = books[i].title + ' ' + books[i].author;

Choose a reason for hiding this comment

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

You are using both ways to create a string here, I think it could be nicer (and less error-prone) if you'd use the same way for both.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@@ -28,18 +56,21 @@ function main() {
author: 'Don Norman',
isbn: '978-0465050659',
alreadyRead: false,
bookUrl: 'assets/the_design_of_everyday_things.jpg',

Choose a reason for hiding this comment

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

Good idea to add the url for the book image! The naming of the key is somewhat misleading though, since this is not a url to the book, but to the image of the book. Could you think of a better name?
It is also not necessary to use book in the key, since we already know it's a book object. That's why we also don't see bookAuthor or bookIsbn.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

}

// TODO execute `addCurrentTime` when the browser has completed loading the page
window.addEventListener('DOMContentLoaded', () => {

Choose a reason for hiding this comment

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

Why did you choose this specific event to listen for?

Copy link
Author

Choose a reason for hiding this comment

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

We need to be sure that our DOM tree is fully completed (ready). Or I need to change it?

isCatCenter = false;
}

if (startPoint >= clientWidth / 2 - widthCat / 2 && !isCatCenter) {

Choose a reason for hiding this comment

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

I have some difficulty with reading this if condition. A lot is happening, and I'm also worried that the order of operations might get messed up with the double division and subtraction. Could you try to rewrite this so that it's a bit easier to read and safer to execute?

Copy link
Author

Choose a reason for hiding this comment

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

fixed

if (startPoint >= clientWidth / 2 - widthCat / 2 && !isCatCenter) {
clearInterval(timerId);
movingCat.src =
'https://media1.tenor.com/images/2de63e950fb254920054f9bd081e8157/tenor.gif';

Choose a reason for hiding this comment

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

It would be nice if the cat walking and dancing sources are a well named const, so that the reader of the code doesn't have to read the URL, but can read "amazingDancingCatGIF" or "slowlyWalkingCatPicture" and know what's being shown in what situation.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

}

// TODO execute `catWalk` when the browser has completed loading the page
window.addEventListener('DOMContentLoaded', () => {

Choose a reason for hiding this comment

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

Why did you choose this specific event to listen for?

Copy link
Author

Choose a reason for hiding this comment

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

We need to be sure that our DOM tree is fully completed (ready)

Copy link

@RHSebregts RHSebregts left a comment

Choose a reason for hiding this comment

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

Great job, LGTM!

paragraph.textContent = books[i].title + ' ' + books[i].author;
imgBook.src = book.image;
imgBook.alt = `Cover of ${book.title} by ${book.author}`;
// paragraph.textContent = book.title + ' ' + book.author;

Choose a reason for hiding this comment

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

You could still delete this comment, but don't worry about it

Copy link
Author

Choose a reason for hiding this comment

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

okey, I just left it to remember the different way

@@ -56,21 +59,21 @@ function main() {
author: 'Don Norman',
isbn: '978-0465050659',
alreadyRead: false,
bookUrl: 'assets/the_design_of_everyday_things.jpg',
image: 'assets/the_design_of_everyday_things.jpg',

Choose a reason for hiding this comment

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

If I were in a particularly bad mood I would say, "this is not actually the image, but a link to the image, so use imageLink or imageURL", but since it's sunny out and the skies are blue, so I think it's ok!

Copy link
Author

Choose a reason for hiding this comment

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

I was in danger, but it seems we all got lucky with the weather in the Netherlands this spring

@@ -21,30 +21,33 @@ function createBookList(books) {
const listBooks = document.createElement('ul');
listBooks.classList.add('list__books');

for (let i = 0; i < books.length; i++) {
books.forEach((book) => {

Choose a reason for hiding this comment

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

👍

imgBook.alt = `Cover of ${books[i].title} by ${books[i].author}`;

paragraph.textContent = books[i].title + ' ' + books[i].author;
imgBook.src = book.image;

Choose a reason for hiding this comment

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

Don't you just love how much cleaner using book is opposed to books[I]? Also, today I learned: forEach is hella slow, and for ... of is way more performant?
Anyway, code wise, this is all good!

Copy link
Author

Choose a reason for hiding this comment

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

Oh, thank you. Interesting graph and site

Choose a reason for hiding this comment

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

Great, the cats walks well, and the code looks a lot cleaner and more readable!

Copy link
Author

Choose a reason for hiding this comment

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

thanks, but I think the cat's starting to make me crazy. I found it again in the API module

@NStefanchuk
Copy link
Author

Great job, LGTM!

https://www.reddit.com/r/ProgrammerHumor/comments/w92k2i/lgtm/
Now I know what LGTM is :)
Thank you for reviewing my code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants