If you’re looking for the source code, then it’s available in the video.
In this, we’re going to see how to create a full-screen hex colour generator that generates colours randomly.
We’ll create a separate component for generating this colour, and name it RandomColor.
It is used to store the generated colour and also to update the colour on a button click. It’ll help us in updating the colour of the page reactively. 😏
Math.randomgenerates a floating-point value between 0 and 1. On multiplying with n, we will get the value in the range of 0 and n — 1.
Math.floorto get the floor round-off value.
toString()function over the value. We can provide a radix argument to this function which converts the number as per the base value provided. Here, we are using **16 **which is for hexadecimal numbers because hex code colour is made up of hexadecimal numbers 🧐.
#in front of the generated string.