Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Bronze
- var rand;
- function gimmeRandom(){
- rand = Math.floor(Math.random()*10) +1;
- }
- gimmeRandom();
- console.log("The random number is " + rand);
- # Silver
- var count = 0;
- var rand;
- function gimmeRandom() {
- rand = Math.floor(Math.random() * 10) + 1;
- count++;
- }
- function countToRandom() {
- for (var count = 1; count <= rand; count++){
- console.log(count);
- }
- }
- console.log("Counting to a random number");
- gimmeRandom();
- countToRandom();
- console.log("Counting to another random number");
- gimmeRandom();
- countToRandom();
- console.log("There has been " + count + " random numbers");
- # Gold
- var count = 0;
- function gimmeRandom() {
- var rand = Math.floor(Math.random() * 10) + 1;
- count++;
- return rand;
- }
- function countToRandom(rand) {
- for (var count = 1; count <= rand; count++){
- console.log(count);
- }
- }
- console.log("Counting to a random number");
- countToRandom(gimmeRandom());
- console.log("Counting to another random number");
- countToRandom(gimmeRandom());
- console.log("There has been " + count + " random numbers");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement