CSS Master? How well do you know CSS Color Names

CSS Master? How well do you know CSS Color Names
0

#1

PLAY THIS AND FIND OUT

  • I created my own project
  • Made with React and Foundation
  • Tests Your Skills with CSS Color Names
  • Still has bug with localStorage for highest rank
  • Need logic in there so it doesn’t overwrite
  • aside from that small detail its a fun time
  • meant more as entertainment
  • but it will stump you on hard…probably medium too
  • check it out and let me know whatcha think
  • thanks

#2

Haha, I like it!
It’s really easy on Easy, Medium it is okay, but hard is very difficult indeed.

I did notice that some colors repeat right after each other. For example, I received ‘Tan’ one after the other twice in a row.
Not sure how to make it more varied, but something to mention.
I like it.

-OneManStack


#3

hey @1ManStack thanks for the reply. You know what I noticed that too. Now I am not sure exactly what is going on. Once in a while i might get the same color 3-4 times in a row. It is all supposed to be random, with a random number being generated every time. There are only 11-12 colors in easy, i just put the color names in an array and let the random number reference their index.

I use Math.floor(Math.random() * [length of array]) . I just concat additional arrays with harder names for medium and hard.

So either something is funky with my approach, or javascript is just reusing the previous random number sometimes. I suppose it could randomly happen as well, since there are only 12 choices.

Maybe I can put in some logic - for example store that random number separately - and say if new random number equals old random number make a new one.

EDIT: I went back in and added a little recursive function that seems to do the trick. no more repeats.