Community X.

Connect with other creators, share ideas, give feedback and get the latest product updates.

Jan 31

Color Shuffle

Hi Team Editor X, I saw an email about learning to do a color shuffle, in which you gave an example, but I have not heard or found anything more about this. I have done my own shuffles, but each time the page reloads, as it's linked to a new page, it doesn't have the same effect as what you had. Kindly let me know where the tutorial/info is. Thank you

1 answer1 reply
1
Best Answer
Feb 2

Hey! Awesome to see you experimenting with cool code interactions! You can use the code snippet below, that's the function we used to create random colors when you click on links in this example:


function getRandomColor() {
  let letters = `0123456789ABCDEF`;
  let color = ``;

  for (let i = 0; i < 6; i++) {
        color += `${letters[Math.floor(Math.random() * 16)]}`;
    }

  return `#${color}`;
}

The function generates and returns a random HEX color code.

Great, thanks for sharing - I'll give it a try!

Editor X

Design your boldest creations.