Loop Olympics

The exercise will get progressively harder and hard. You at least should get one medal, but feel free to go the extra mile!


Preliminaries
  1. Write a for loop that prints to the console the numbers 0 through 9.
  2. Write a for loop that prints to the console 9 through 0.
  3. Write a for loop that prints these fruits to the console.
    var fruit = ["banana", "orange", "apple", "kiwi"]

Bronze Medal
  1. Write a for loop that will push the numbers 0 through 9 to an array.
  2. Write a for loop that prints to the console only even numbers 0 through 100.
  3. Write a for loop that will push every other fruit to an array.
    var fruit = ["banana", "orange", "apple", "kiwi", "pear", "peach"]

Silver Medal
  1. Write a loop that will print out all the names of the people of the people array
  2. Write a loop that pushes the names into a names array, and the occupations into an occupations array.
  3. Write a loop that pushes every other name to an array starting with "Harrison Ford", and every other occupation to another array starting with "Singer".
var peopleArray = [
  {
    name: "Harrison Ford",
    occupation: "Actor"
  },
  {
    name: "Justin Bieber",
    occupation: "Singer"
  },
  {
    name: "Vladimir Putin",
    occupation: "Politician"
  },
  {
    name: "Oprah",
    occupation: "Entertainer"
  }
]

Gold Medal
  1. Create an array that mimics a grid like the following using for loops:
[[0, 0, 0], 
[0, 0, 0], 
[0, 0, 0]]

2.Create an array that mimics a grid like the following using for loops:

[[0, 0, 0], 
[1, 1, 1], 
[2, 2, 2]]

3.Create an array that mimics a grid like the following using for loops:

[[0, 1, 2], 
[0, 1, 2], 
[0, 1, 2]]
  1. Given a grid like the previous ones, write a for loop that would change every number to an x.
var grid = [[0, ...], 
            [0, ...], 
            [0,...], ...]