Saturday, February 4, 2017

JS30 Challenge Day 30 - Whack a mole


'click' event has a .isTrusted property which can check for fake clicks generated by javaScript.

random*(max-min)+min; //explained:
random always assumes a value between 0 and 1
max-min gives us the difference between the two edge values
so a decimal between 0 and 1 is multiplied times the difference, which can possibly give us a max of the difference times 1, the max possible value, or it could give us a zero.
The final + min ensures that the minimum possible value if the difference between max and min is 0, will be the min value itself. So it basically offsets the value of max-min by the value of min itself, so we get a valid number!

No comments:

Post a Comment