Solution Review: Make a Scale

This review provides a detailed explanation of the solution to the "Make a Scale" challenge.

We'll cover the following

Solution

Console
Solution of the challenge

Explanation

Let’s dive into the following explanation to better understand how the above code works.

  • The most important part of this coding challenge is the selection of the correct scale. Both the input and output are discrete, so we have selected the scaleOrdinal scale and initialized it in line 3.
  • In line 4, we have set our domain of the c_scale to the courses array using the domain() function.
  • In line 5, the range of c_scale is initialized to timings using the range() function.
  • Using console.log in line 6, we can see the output of the c_scale on the console.

Note: You can add the unknown function in the solution which will take care of the invalid inputs.