Hi, thanks for the post, it helped me learn a thing or two.
I think I may be able to help with, or give advice.
For example, when you write your createGrid function, you write the entire grid style in your markup constant, however it would maybe be better if you only put the classes and id and actually define the rules in a css file, using either your id or class as a selector (whichever is more appropriate).
Secondly, I don't know if you actually know it but maybe instead of using lambdas with the const name = (params) => { /*code*/} syntax you probably could use the function keyword which lets you define a function with code like:
functioncreateGrid(){//code}
This code will define a named function, the use would not be different in code.
This is up to your personal preference in the end.
Then, as a tip, when using a for loop to go through an array, the in keyword lets you go through the keys. For example:
Thirdly, document.querySelector and document.querySelectorAll can retrieve any element using css selectors for example:
letfirstDiv=document.querySelector("div");// you can search inside any other element you retrieved as this is a function with HTMLElement type objectslettitles=firstDiv.querySelectorAll("p .title");// querySelectorAll returns an HTMLCollection, not a simple array!
Lastly, for a bit of nitpicking, at the end, you use three script tags in your HTML to call each individual functions, you can put it all in one and it will work just fine, as long as you don't forget newlines/semi-colons.
I would advise you to put the code in it's own "main.js" file though.
Now maybe that in the time between your original post and this comment you have picked on a bit of what I say here, and I'd like to say that what I say is not an absolute truth you should follow either, that's just how I learned, and I hope I could help you learn too!
I'm Jake Cahill. Lifetime Pythonista, web scraping and automation expert. Enjoy books. Love my wife, dog, and cat, and think AI and Julia are pretty nifty
Location
Maine, USA
Education
A Master's patient mentorship and insatiable curiosity
Thank you so much for your reply! To be totally honest, I am a Python developer and wrote this post to try and encourage myself to get better acquainted with the JS standard library.
1) thanks so much for offering constructive criticism! It is one of my greatest joys to interact with better developers than myself and I really appreciate your suggestions!
2) I would hardly call your criticisms "nitpicky", but thank you for being tactful 😁. I'm sure it was easy to see that I am making there Cardinal mistake of approaching my target language (JS) the same way I would my source language (Python) so feel free to give me "the business" about how to make it right.
😁😁
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi, thanks for the post, it helped me learn a thing or two.
I think I may be able to help with, or give advice.
For example, when you write your
createGrid
function, you write the entire grid style in your markup constant, however it would maybe be better if you only put the classes and id and actually define the rules in a css file, using either your id or class as a selector (whichever is more appropriate).Secondly, I don't know if you actually know it but maybe instead of using lambdas with the
const name = (params) => { /*code*/}
syntax you probably could use thefunction
keyword which lets you define a function with code like:This code will define a named function, the use would not be different in code.
This is up to your personal preference in the end.
Then, as a tip, when using a for loop to go through an array, the
in
keyword lets you go through the keys. For example:can become :
Thirdly,
document.querySelector
anddocument.querySelectorAll
can retrieve any element using css selectors for example:Lastly, for a bit of nitpicking, at the end, you use three
script
tags in your HTML to call each individual functions, you can put it all in one and it will work just fine, as long as you don't forget newlines/semi-colons.I would advise you to put the code in it's own "main.js" file though.
Now maybe that in the time between your original post and this comment you have picked on a bit of what I say here, and I'd like to say that what I say is not an absolute truth you should follow either, that's just how I learned, and I hope I could help you learn too!
Thank you so much for your reply! To be totally honest, I am a Python developer and wrote this post to try and encourage myself to get better acquainted with the JS standard library.
1) thanks so much for offering constructive criticism! It is one of my greatest joys to interact with better developers than myself and I really appreciate your suggestions!
2) I would hardly call your criticisms "nitpicky", but thank you for being tactful 😁. I'm sure it was easy to see that I am making there Cardinal mistake of approaching my target language (JS) the same way I would my source language (Python) so feel free to give me "the business" about how to make it right.
😁😁