Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // For Loops
- // Documentation:
- // W3: https://www.w3schools.com/js/js_loop_for.asp
- // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for
- // Create a `for` loop which runs 10 times, and console logs out the index for each iteration
- // Create a `for` loop which runs 10 times, and increments the index by two each iteration
- // Also console logs the index for each iteration
- // Create a `for` loop which runs 100 times, and console logs out only the indexes which are
- // multiples of 3
- // Create a `for` loop which runs 100 times, and console logs out only the indexes which are
- // even numbers
- // Create a `for` loop which runs 100 times, and console logs out only the indexes which are
- // odd numbers
- // Create a `for` loop which runs 100 times, and console logs out only the indexes which are
- // multiples of 5
- // Create a `for` loop which runs 25 times, and increments the index by three each iteration
- // Also console logs out the index - 30, but only for values which will result in a positive integer
- // for example if index is 20, you cannot subtract 30 because the result would be -10
- // Create a `for` loop which runs 100 times in reverse, and console logs "time till explosion" along
- // with the index number
- // Create a `for` loop which runs 50 times in reverse, and decrements the index by 4, and console logs
- // "turbo modes engages in " along with the index number
- // While loops
- // Documentation:
- // W3: https://www.w3schools.com/js/js_loop_while.asp
- // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while
- // Create a `while` loop which runs 10 times, and console logs out the index for each iteration
- // Create a `while` loop which runs 10 times, and increments the index by two each iteration
- // Also console logs the index for each iteration
- // Create a `while` loop which runs 100 times, and console logs out only the indexes which are
- // multiples of 3
- // Create a `while` loop which runs 100 times, and console logs out only the indexes which are
- // even numbers
- // Create a `while` loop which runs 100 times, and console logs out only the indexes which are
- // odd numbers
- // Create a `while` loop which runs 100 times, and console logs out only the indexes which are
- // multiples of 5
- // Create a `while` loop which runs 25 times, and increments the index by three each iteration
- // Also console logs out the index - 30, but only for values which will result in a positive integer
- // for example if index is 20, you cannot subtract 30 because the result would be -10
- // Create a `while` loop which runs 100 times in reverse, and console logs "time till explosion" along
- // with the index number
- // Create a `while` loop which runs 50 times in reverse, and decrements the index by 4, and console logs
- // "turbo modes engages in " along with the index number
- // For In Loops
- // The following For In loops will make use of this loop Object below
- // Documentation:
- // W3: https://www.w3schools.com/jsref/jsref_forin.asp
- // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in
- var loopObject = {
- index_1: 1,
- index_2: 2,
- index_3: 3,
- index_4: 4,
- index_5: 5,
- index_6: 6,
- index_7: 7,
- index_8: 8,
- index_9: 9,
- index_10: 10,
- }
- // Create a `for in` loop which loops through the `loopObject` and
- // console logs out each of the property names
- // Create a `for in` loop which loops through the `loopObject` and
- // console logs out just the values for each of the property names
- // Create a `for in` loop which loops through the `loopObject` and
- // console logs out the following string for each property with the
- // properties and values concatenated into it
- // "The property name is [property name] and the value is [property value]"
- // The following For In loops will make use of this loop Object below
- var person = {
- name: "jimmy",
- age: 32,
- dog: false,
- cat: true,
- favorite_food: 'sushi',
- favorite_number: 42,
- favorite_movie: "Tron: Legacy",
- greatest_fear: "clowns",
- favorite_song: "",
- hours_of_sleep: null
- }
- // Create a `for in` loop which loops through the `person` object and
- // console logs out only the property values which are `strings`
- // Create a `for in` loop which loops through the `person` object and
- // console logs out only the property values which are `falsy`
- // Create a `for in` loop which loops through the `person` object and
- // console logs out only the property values which are `numbers`
- // Create a `for in` loop which loops through the `person` object and
- // console logs out only the properties which contain `falsy` values
- // Create a `for in` loop which loops through the `person` object and
- // console logs out only the properties which contain `number` values
- // Create a `for in` loop which loops through the `person` object and
- // console logs out only the properties which contain `string` values
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement