Simple Javascript function

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.

Habilidades: HTML, Javascript

Veja mais: javascript rgb hex, javascript set background color, javascript decimal format, convert rgb hex, background color javascript, number function, function number, function - 1 to 1, javascript less than, simple javascript, Concatenate, javascript display object, upon javascript, generate random number, javascript single page, javascript support, html object, javascript math function, function time, javascript background color, math javascript function, simple zoom function javascript, simple math, random number display, html random background

Acerca do Empregador:
( 22 comentários ) Sunnyvale, United States

ID do Projeto: #5123491

Concedido a:


I'm available can give you in 30 minutes or so....once you assign the project. I'm reading to start working on the project. Looking forward to working with you. Awaiting a positive reply from you. Thanking you Sha Mais

$14 USD em 0 dias
(1 Comentário)

10 freelancers are bidding on average $25 for this job


Hi, i have read your project description, and i understand what you want. I have strong knowledge of JavaScript, and know exactly what's need to be done, so i can finish this project without any hesitation and errors. Mais

$30 USD em 1 dia
(61 Comentários)

Hi. It's very with me. I can give you my product today. Looking forward to working with you!!!!!!!!!

$30 USD in 20 dias
(6 Comentários)

Hello, Experienced frontend developer at your service; I can do the javascript you demand within hours if you are in a hurry. Thanks in advance.

$30 USD in 0 dias
(6 Comentários)

I can do this today. Thank you .

$24 USD in 2 dias
(5 Comentários)

READY TO START YOUR WORK NOW... s k ype bhagyavendra1 NO NEED TO PAY [url removed, login to view] I WILL GIVE YOU UPDATE THEN YOU CAN CREATE MILE STONE PAY [url removed, login to view] [url removed, login to view] http://www Mais

$33 USD in 0 dias
(11 Comentários)

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!

$20 USD in 0 dias
(1 Comentário)

A proposal has not yet been provided

$78 USD in 3 dias
(1 Comentário)

Hi, My name is David and I am working as a Project Coordinator for Offshorent, located in Philadelphia suburbs. We are interested to have a long term relationship with you. Availability: Immediately / Daily We p Mais

$27 USD em 1 dia
(0 Comentários)

Hi, am a web developer with experience in HTML5,CSS3,JavaScript,JQuery,PHP5,Smarty,MySql,Wordpress..., you can contact me for further details. Regards, Younes

$35 USD in 0 dias
(0 Comentários)

Ainda não foi fornecida uma proposta

$20 USD in 4 dias
(0 Comentários)

Hi, I am a software engineer and have been working on front end development for more than 3 years. The javascript you need is pretty simple and i can code it for you within an hour. Thanks.

$25 USD in 3 dias
(0 Comentários)

Hi there, I have 5 years expirience in Javascript, PHP , Wordpress and Web development. If you want just something - go with indians, but if you want something really professional - looking work - you can trust me! Mais

$25 USD em 1 dia
(0 Comentários)