Interactive two-state rating component solution using JavaScript
Design comparison
Solution retrospective
- Is my JavaScript at least serviceable?
- The challenge description is calling the 'rating' and the 'thank you' parts states. Is it a refrence to some component or framework that I don't know about?
Community feedback
- @DavidMorgadePosted about 2 years ago
Hey Fobya I didn't see your rating component, before so I just came here from your other project, I want to answers your questions and also check your code!
Just a little question before starting, you did programm before using maybe C# right?
Alright, let me try to answer your questions:
Is my JavaScript at least serviceable?
- Yeah I think is doing the job, you could also go for the shorter way using an
onSubmit
event instead of an onclick, but this just do the job, and doesn't require to use an html form. Good job using Array methods, you did this solution with a declarative way more than an imperative, you are not telling your code to 'get this rating and this will be the rating', you are doing it like 'when clicking this, set disabled to false, then in other function if disabled is false, set the selected value to the elements value', wich is an approach that I like a lot since its the one that is used on React. Also, try to not usevar
, it can cause you some scope issues on larger projects, if you need a variable that changes like the selected rating, uselet
.
The challenge description is calling the 'rating' and the 'thank you' parts states. Is it a refrence to some component or framework that I don't know about?
- Those are words that are usually use in some frameworks like react, but in this case I thing that they are pointing to different situations that your applications might be, think it like in process and completed, in React for example, you have the state wich is parts of your application that can be manipulated or declared by you using hooks, this can be a whole blog post just talking about state, but just think of it as a 'screenshot' of your application that you can manipulate using a 'function'
Hope my feedback helps you, I recommend that if you wanna go for Angular, start right now doing the challenges with Typescript, since its a must for Angular and I think that you already have experience with strongly typed programming languages
Marked as helpful1@zofia-mmPosted about 2 years ago@DavidMorgade
Thanks for pointers! :)
I haven't used C# and ain't really good with C. I'm from the Java camp, so have experience with that and Kotlin. I also know a bit of Python. I've got a sliver of experience (for class) with JavaFX and Android and I've learned quite a lot of Jetpack Compose on my own.
I'm pretty good with declarative stuff, probably from Compose, but I've also tackled Haskell and Prolog (again, for class) - and loved it.
1@DavidMorgadePosted about 2 years ago@Fobya7 I was thinking C# at first because the way you used curly bracers, but as I said yes, your programming styles is a lot declarative and functional than a "standart" Javascript developer
1 - Yeah I think is doing the job, you could also go for the shorter way using an
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