hello friends welcome to coding session today in this tutorial we will be looking at a library
called as random color so it is an open source library for generating some random colors
in javascript so this is the github link of this library so in order to include this library
you will need jquery so i have already included the cdn for jquery and also if you go to google
here just type here random color cdn so the first text which comes in you can see that
so just copy there is a cdn of that also so various cdns are also there you can just take
this cdn win.js just copy this and paste it above your after your jquery is imported so
just paste it here after this is my script.js so in order to generate a random color with
the help of this library let me create a new variable of color and the function is very
simple random color that's it so this will generate a hash code for the color so i can
just change the body first of all let me just print it in the console
so if i open developer tools you can see that it has been rated in three decimal random color
so if i refresh this you will see it is changing here so now if i want to set the background color of the body so document.body.style.background
is equal to color so now you can see that the color has changed here green violet so
whenever i refresh the page it will change the color you can see that and also it can
paste some options so it can return if you want to provide some options custom options
so there is a count option which lets you return 10 colors so if i control lock it will return an
array so you can see that 10 colors are returned so you can pass as much number as you want let
me pass 100 so you will see that it will return 100 hexadecimal codes so based upon that if you
refresh as this is an array you need to be using a for each group so for each array is color and
let me take an index variable also called as color and just you have to write the document.body.style.background
is equal to color that's it so now you can refresh the page and then you can see that
these 100 colors will be applied to the body as well apart from this you have some more
options in order to create some specific colors you can see that this is a view option you can
view is equal to green so it will be generating the green related colors
green is not defined so you need to put it in the single quote so you can see that it will return the green related colors which is
just with the help of this property you can just provide any color let's suppose red
reflective so you can see that red head related color there are based upon that there are various options you can also use RGB
you can change the luminosity property as well so let me provide this as bright
and the format let me provide this in RGB so now you can see that the colors are returning in a red green blue format you can see that
these are all bright colors so in this way you can generate
some random colors using this library called as random color