Upon loading the page, use the Math object to randomly generate a Web color in hex format and set the background color with this random color.
Web color can be expressed either in hexadecimal notation, or as an RGB value. With the RGB value, each color is represented as a number between 0 and 255. Older browsers may not support the RGB notation.
Use the hexadecimal notation (e.g. #ffffff, R=ff, G=ff, B=ff). First generate a random number between 0 and 255 for Red, Green and Blue. Then convert each number to hex number by using toString(16) (e.g. if the varibale for Red is r, then convert by doing [url removed, login to view](16)). Since a decimal value of something like zero converts to a single-digit character and the format needs to be double-digit, the length is tested and modified accordingly. this means that the length of the generated number must be checked to see if it's less than 2. If so, concatenate 0 to it. Finally the hex number is created by contatenating RGB.
Set the background color to the randomly generated color. Display a text and the hex number for the color.
Refreshing the page will give a different color each time.
10 freelancers are bidding on average $25 for this job
hello, I can do this for you as i am expert in Java script and j query i will deliver you this in no time see my reviews and recent works waiting for your response to start as soon as possible. Thank You!