Feedback is appreciated
achrustowski
@achrustowskiAll comments
- @RuFuRuSubmitted about 2 years ago@achrustowskiPosted about 2 years ago
Hi RuFa,
Congrats on your solution! It looks great and it's a nice touch to have a prompt for Custom tip value :)
As for improvements, you have some repetitions in you JS code, you could put
gridButtons.forEach(btn => { btn.setAttribute('style', 'pointer-events: auto'); btn.classList.remove('btn-clicked'); });
andbutton.classList.add('btn-clicked'); button.setAttribute('style', 'pointer-events: none');
inside of a function and call it whenever you need to use it. This will clean up the code a little bit and make it more readable.Lastly, completely UI thing, looks like your 15% button is clicked by default, not sure if this is intended, just my observation.
Hope this help! Adam
Marked as helpful1 - @SouiciaSubmitted about 2 years ago
Hello everybody!
Finished my second challenge in JavaScript. This one was interesting! Add some problems with SCSS, for JavaScript it was alright. However, if anybody did this challenge, I will gladly take any advice on the JS (mainly if there is a way to reduce the amount of document.getElementById).
@achrustowskiPosted about 2 years agoHi Leo!
I really like your solution, logic works as expected and everything does it's job as it should, well done! :)
As for reducing the amount of
getElementById
I don't think there is any other way if you're using vanilla JavaScript (I've done my solution similar way to yours). Only thing I'd change in order to make your life easier IF you had to edit your JS code, I'd putthrowErrorMessage
selectors into variables same as you did for buttons and inputs.Great job!
Marked as helpful1 - @achrustowskiSubmitted about 2 years ago
What I always think about when coding each challenge is whether or not to write my code like I would do for a real life project (so considering that it might be edited a year or two after) or just to make everything look like on the design and not really consider any future updates/ changes.
At the moment I always try to make my code easily editable and as I would code for if I was hired by someone to do it.
How do you guys approach this?
Cheers! Adam
@achrustowskiPosted about 2 years agoHi @correlucas,
Thanks very much for your feedback. I indeed have been using semantic elements in my previous solutions, but then what I would get is accessibility issues.. not sure why.
Any idea why when I use semantic elements I'm getting accessibility issues?
Cheers, Adam
0