Q:

Write a JavaScript program to generate a random hexadecimal color code

0

Write a JavaScript program to generate a random hexadecimal color code.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const random_hex_color_code = () => {
  let n = (Math.random() * 0xfffff * 1000000).toString(16);
  return '#' + n.slice(0, 6);
};

console.log(random_hex_color_code())

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now