Generate a random hex code (color) in under 400 characters

I made this:

#$(eval var sayings = [‘0’,‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’,‘A’,‘B’,‘C’,‘E’,“F”]; sayings[Math.floor(Math.random() * sayings.length)];)$(eval var sayings = [‘0’,‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’,‘A’,‘B’,‘C’,‘E’,“F”]; sayings[Math.floor(Math.random() * sayings.length)];)$(eval var sayings = [‘0’,‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’,‘A’,‘B’,‘C’,‘E’,“F”]; sayings[Math.floor(Math.random() * sayings.length)]:wink:

which gives me the 3 out of the 6 values but then I hit the character limit and can’t complete the command.

This is code I’ve seen for picking a random number between 1 and 1,000,000 ten times:

$(eval x=``;for(a=0;a<10;a++){y=Math.floor(Math.random()*1000000)+1;x+=y+ }x)

But it’s all numbers and the code I’m using has numbers AND letters

Hey @evalhelpquestion!

You can just use the same array and random-pick function multiple times:

$(eval o = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; r = (a) => a[Math.floor(Math.random() * a.length)]; `#${Array.from({length: 6}, () => r(o)).join('')}`;)

Be careful to use the proper quote marks: ' instead of ‘’, or " instead of “”.
Also, you had forgotten D.

1 Like

Amazing and perfect, thank you!!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.