Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function randomPointOnCircle(radius) {
- // Pi or π is a mathematical constant equal to a
- // circle's circumference divided by its diameter.
- var angle = Math.random() * 2 * Math.PI;
- // Math.random() 0 - 1 pseudorandom number in that range
- return {x: radius * Math.cos(angle),
- y: radius * Math.sin(angle)};
- }
- console.log(randomPointOnCircle(2));
- function randomZeroToN(n) {
- return Math.floor(Math.random() * n);
- }
- // Generate random number 0 - n
- var counter = 0;
- do {
- console.log(randomZeroToN(100));
- counter++;
- } while (counter < 10);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement