Design comparison
Solution retrospective
Thank you guys to check my really first project with js! I have a question if somebody would check my work, about the Javascript file. In the index.js i save the selected vote (1 or 2 or etc) with addEventListener, and a function that store the value in a new variable to bring it in the second html page.. well, i was wondering if it was possible to do it without the eventListener, if there is another way to store a variable from a selected button after a click. This way is really short, but even if i used it i don't really understand it (i copied from a project a did during the js course). I mean, for me the addEventListener should be used to add an event, such as play a sound, show an image, text, or something that happen (the event) after the click, but in this case i used it only to take out a value and put it inside a variable, is there a more "proper" way to do it? Thanks everybody for the suggestions and happy coding!!
Community feedback
- @florianstancioiuPosted almost 2 years ago
Hi Ric,
You shouldn't have 2 index files, and localstorage shouldn't be used in this project. You can take a look at how I did the challenge here: https://www.youtube.com/watch?v=oZJb_GPAlc4 The JavaScript part is done at the end of the video, you can also find the code in the description of the video.
Marked as helpful0@Ripra87Posted almost 2 years ago@florianstancioiu Hi Florian, yes at the beginning i also thought to add a hidden class, but i started thinking about the JS code only after writing the 2 html and css pages, and i was really lazy to code all again :P Anyway i agree, your way is better. I'm a beginner with JS and it tooks so much time to write those few lines of code, i even didn't know the localStorage before, i learnt it specially for this challenge :P BTW really nice Ytube page, i'll check it now after every challenge to see how i could have done it in a better way!
1
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord