Guest User

Untitled

a guest
Jul 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. const colors1 = ['#111', '#222', '#333'];
  2. const colors2 = ['#444', '#555', '#666'];
  3.  
  4. const colorChoice = (n) => {
  5. return n[Math.floor(Math.random() * n.length)];
  6. };
  7.  
  8. colorChoice(colors1);
  9. // Returns one of: ['#111', '#222', '#333']
  10.  
  11. colorChoice(colors2);
  12. // Returns one of: ['#444', '#555', '#666']
Add Comment
Please, Sign In to add comment