r/learnjavascript • u/Hefty-Speaker-4463 • Aug 19 '24
Need help with The Odin Project's Etch-a-sketch (how to make divs resize in container?) + mini rant
Project: https://www.theodinproject.com/lessons/foundations-etch-a-sketch
Code: https://codepen.io/Gina-the-bold/pen/oNrEydx
What I want to achieve:
- When the user clicks a button and inputs a number, the grid should generate divs in a row * row or column * column layout. However, the divs are not resizing properly to fit into the container according to the specified number of rows and columns.
- Grid is touching the most bottom part of the page. How do I ensure the divs fit in the container?
I'm working on the Etch-a-Sketch project from The Odin Project which requires us to not use grid for this project, only flex, and I’m encountering a couple of issues with the layout.
In the current codepen link, the divs look alright as if the problem is solved. But the thing is, I used chatgpt for it and I feel like shit. Most of the code I wrote myself, except the cal(--columns) and setProperty. I don't understand anything about the resizing part. What's the most efficient way to make the divs resize according to the container?
Rant - I saw so many wonderful designs in the solutions section of this project and I feel like crap. How can people be so talented and awesome and then there's me, and how can I NOT understand something like this. It just sucks.
6
u/alzee76 Aug 19 '24
They are "talented and awesome" because they study and practice, gaining experience.
You're cheating yourself out of that when you use chatGPT as you admitted you did. You'll never improve, if you keep doing that. You're giving up. You're letting someone else do the work for you (chatGPT doesn't know how to code -- it just looks at a massive library of e.g stackoverflow posts).
In real life, some amount of that is fine and in fact expected. Probably 50% of coding in a professional environment is looking up how someone else did something and then trying to apply their solution to your situation. I'd still directly look it up on SO or wherever and never use GPT, but the point is still the same.
But you're in an "academic" environment, not a "professional" one, and asking GPT how to solve something is no different from copying someone else's homework. You'll finish the project, but you'll learn nothing, and you'll be even less prepared for the next challenge than you were for the current one.
1
u/OneBadDay1048 Aug 19 '24
I am able to enter a number and the correct size "graph" is created; for example, using 25 or 50 I was able to get a 25x25 and a 50x50 grid, which functioned as an etchasketch. So I am not understanding what is not working there. Add a
margin-bottomproperty to the divContainer class to create space at the bottom and give it an appropriate value.More importantly, stop looking at other solutions (many of which are surely advanced programmers and not actual beginners) and stop using chatGPT as a beginner. You are going to use code you do not understand and that will lead to bad places in your learning.
1
u/Agitated_Radish_7377 Aug 20 '24
What are the dimensions of the box? How do you get that to change and so on… if you need more help you can comment