@Yazdun
Posted
Hello Nyein and great job š I have some suggestions on this :
- First, Wouldn't it be cooler if button had some hover effects? š
- I noticed you've been used
div
for form which is not best approach, best is useform
tag itself and on submit you can use something like
btn.addEventListener("click", (e) => {
e.preventDefault();
validateForm();
});
- For javascript, I noticed so many
if
andelse
which was not necessary, you can write a function for that then just pass the parameters to the function, so you can totally avoidif
andelse
repetition.
Here I have some good resources that you maybe interested in :
- DRY principle
- Javascript nuggets playlist and Javascript fundementals by John Smilga š„
ā
Also I opened a pull request to your solution repo which will add a function to validate your inputs so you can get rid of some of those if
and else
, Also I added some hover effects to your button I hope you're ok with that š
SIDE NOTE: For validate function, I wanted to add a foreach
loop so we wouldn't need to call the function 4 times, but I thought it would get too complicated and so different from your code, so I kept it simple a little bit. You can look into map
function yourself later on.
I hope this was helpful
Marked as helpful
@CrystalNyein
Posted
@Yazdun Thank you so much. I'm still on my way learning so these feedbacks are very valuable for me. It'll help me improve my coding styles a lot. I'll try that function too. Thanks for the pull request too so that I can check out how I can change those code in the future usage.
@Yazdun
Posted
@CrystalNyein Glad I could help