Daily post #11 – I just wrote a piece of code to generate a random hex color code. Here’s what it looks like:
- 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.
- This random number will be a part of an array which also contains characters from a to f.
- Now we randomly select one of the items from the array and keep concatenating them till the count is 6.
- And that generates a hex code 🙂