Setup

  • Open up a markdown file in your personal repo, and add it to your blogs as “Javascript Hacks - Lesson 3.10”

  • To start off, create a < script > tag at the beginning and a </ script > in order to start using Javascript

  • In order to see your “console.log”, right click the page, click “inspect” and click on console. This will allow you to work with javascript and complete your homework.

JavaScript Homework

Problem #1: Basic Array Creation

Create an array in JavaScript with at least 5 values. Then, use console.log() to display the array.

Bonus:

Use the reverse() popcorn hack to reverse your array

Problem #2: Accessing Elements

Given the array sports = [“soccer”, “football”, “basketball”, “wrestling”, “swimming”], write code that will display the values “soccer” and “wrestling” using their indexes. Use console.log() to show the output.

Problem #3: Adding and Removing Items

Create an array called choresList initialized with four items of your choice. Write code using push(), shift(), pop(), and unshift() to change the list. Use console.log() to display the output each time you change the list.

Bonus:

Use the push() and spread operator popcorn hack to add multiple values to your choresList at once

Problem #4: Iteration and Conditionals

Create an array that contains ten random numbers (both even and odd). Write a function that iterates through the entire array and counts how many times an even number appears in the list. Return the count and display the output using console.log().

When you’re done, submit/show a picture of your console.log.

Homework scaling

0 = .00 work, but faking understanding/accomplishment

1 = .55 incomplete assignment, big gaps

2 = .75 meeting some objectives, multiple little gaps

3 = .85 meeting most objectives, one little gap

4 = .90 meeting all objectives

4+= .95 Utilizes all the popcorn hacks, and comples the Bonus effectively