Rating Credit Scores: Solution Review
Understand how to apply RamdaJS functional programming techniques to process and rate credit scores. Learn to use map for iteration and cond with point-free style functions to replace complex if-else logic, enhancing clarity and efficiency in your code.
We'll cover the following...
Since score is an array of numbers, we know map's involved. It lets us loop and transform each score as we see fit.
What would we do with each score? Let’s review the challenge.
- At or above 800, return “{score} is excellent!”
- At or above 700, return “{score} is good”
- At or above 650, return “{score} is fair”
- At or below 649, return “{score} is poor”
Imperatively, that sounds like a bunch of if/else statements.
Luckily though, Ramda has us covered. cond can easily replace this logic with functions!
It does look a bit confusing with all the arrows, however.
If you’d like to make the comparisons point-free, try gte and lte.
Now compose it with map to review all the scores!