I’ve started mentoring three sessions of the Resistor Color Trio exercise in the last week, which makes me think that it is a frequent source of confusion.
I think this is an excellent opportunity to talk about the power of using as const objects and keyof typeof, which are features of TS that I use almost daily in my job as a full stack dev. It allows you to write the constant like so:
I think adding mentor notes that explains this would benefit the community (I’ve seen some very strange ways of approaching this exercise), but I would like to discuss it here to make sure we arrive at something that will add the most value. So, I welcome everyone to shoot suggestions.
That being said, the challenges in this functions is the argument constraints and the unit modifier. The strategies to convert the number are either mathematical or string concatenation-based; the modifier can be selected by length or mathematical.
Thanks for the response (and for building this awesome platform )
I did not know about the approaches and articles, that seems like a great option for my solution specifically, so I will definitely try to write one.
However, I would still like to collaborate on writing more generic mentor notes too (which does not have to include my solution). I just feel like the amount of people asking for mentoring on this exercise is an indicator that mentor docs would be useful. I was hoping to use this thread to gather the various topics and notes that we can include in the mentor notes. I’m completely open for the final result to take any structure that would contribute towards this goal.
Thanks for these suggestions! The tuple is definitely a good shout. The approach of doing the multipliers in an array is also interesting, but I’m inclined to think that it decreases readability for not that much gain. But it certainly is cool a cool way to solve the problem.
I think having different sections for the function signature, the types used for the conversion, the conversion itself, and for adding the unit sounds like a good starting point. What do you think?
You can certainly write mentor docs - that’s great too. It’s just they don’t necessarily directly help students - they more help mentors mentor well (which might also of course benefit students). Whereas the Approaches/Articles are student-facing so of higher immediate impact.
I’d suggest starting by writing an Approach, focussing on your preferred way of doing it, as you can be quite autonomous in that. Then the mentor notes can maybe be more of a collaberative effort