Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <script>
- //create the function that console logs every number from the firstNum to the lastNum
-
- function simpleLoop( firstNum, lastNum ){
-
- }
- simpleLoop(0, 8);//0, 1, 2, 3, 4, 5, 6, 7, 8
-
- //create the function that takes in 1 number, and console logs out every number from 0 down to this number. the number will always be less than 0
- function backwardsLoop( ){
- }
-
- backwardsLoop( -5 ); //0, -1, -2, -3, -4, -5
- backwardsLoop( -2 ); //0, -1, -2
-
- //create the function that takes in 1 number. it console logs all the numbers from 0 to this number. It may be postive or negative!
- function biDirectionalLoop(){
-
- }
-
- biDirectionalLoop(-3); //0, -1, -2, -3
- biDirectionalLoop(4); //0, 1, 2, 3, 4
-
- //create the function that takes in 2 numbers.
- //logs out every number from 0 to the first num
- //increments by the second number
- //will always be postive
- function jumpLoop(){
-
- }
- jumpLoop(10,2); //0,2,4,6,8,10
- jumpLoop(1000, 100)// 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000
-
- //create the function that takes in 4 positive numbers
- //console logs out 2 numbers
- //the first is where to end the first number, second is how far to increment
- //3rd is where to end second number, the other is how far to increment
- //stops the loop when either number reaches the end
- //both numbers start from 0
- function dualDirection(firstEnd, firstDistance, secondEnd, secondDistance){
-
- }
-
- dualDirection(3, 1, 10, 2); // 0, 0, 1, 2, 2, 4, 3, 6
- dualDirection(1000, 250, 10, 3);//0,0,250,3,500,6,750,9 //would end because 12>10
-
- //don't modify this function, it will be used next
- function getRandomNumber( min, max ){
- var randomPercent = Math.random();
- var scaledNumber = randomPercent * (max-min+1) + min;
- var wholeNumber = Math.floor( scaledNumber );
- return wholeNumber;
- }
-
- //make a function that keeps looping until the random number it gets is greater than the passed in number
- //call the getRandomNumber function with arguments 1,10
- function stopWhenGreater( targetNum ){
- console.log('starting');//do this, so we know it started to run
- //example of call: var num = getRandomNumber(1,10)
- }
- //these numbers are examples. they will be random and therefore could be anything
- stopWhenGreater(5);// 'starting', 3, 1
- stopWhenGreater(9);// 'starting', 8, 4, 5, 2, 1, 9
-
-
- //fibonacci loop
- //start with 2 numbers, 0 and 1.
- //keep looping them while the combined result is greater than the target
- //hint: you should not need to make more variables. move one number
- //into the other number and then result into the first num
- function fibonacciLoop( targetNumber ){
- var result = null;
- var num1 = 0, num2 = 1;
- while(result < targetNum ){
- //?
- console.log(result);
- }
- }
- </script>
- </head>
- <body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement