Grad Project 1: Arrays & Looping

by Keeley Peck

HTML

<h3>Solutions: Arrays &amp; Looping</h3>
<h4>4 Tasks for this Practice Set:</h4>
<ol>
  <li>
    Make an Array of strings and assign it to a variable. You may make the strings a list of anything you like and use a variable name of your choice.</li>
  <li>
    Write a <code>while</code> loop to iterate over each element in your Array and write each one to the console.</li>
  <li>
    Use one of the methods of the Array object to insert a new element to the end of your array. Looking through the methods on the Array reference page at <a href="http://www.w3schools.com/jsref/jsref_obj_array.asp">W3Schools</a> may be helpful.</li>
  <li>
    Using the same conditions as you had in your <code>while</code> loop, write a <code>for</code> loop to iterate over each element in your Array and write each one to the console.</li>
</ol>

JavaScript

"use strict";

// Insert your code for #1 here


// Group the output of the array elements in the console 
// for easy differentiation between the While and For loop results
console.group("While loop:");

// Insert your code for #2 here


console.groupEnd();

// Insert your code for #3 here


// Group the output of the array elements in the console 
// for easy differentiation between the While and For loop results
console.group("For loop:");

// Insert your code for #4 here


console.groupEnd();