Script To Generate Random Hex Color Code

Daily post #11 – I just wrote a piece of code to generate a random hex color code. Here’s what it looks like:

Explanation:

  • Create a box and a button
  • Select those using JS
  • Add event listener to the button
  • Connect it with updateButton function
  • This function will generate hex code and insert it inside the box.

My logic was to generate a random number from 0 to 9.