Week 4: Array Methods and Iterators

To Do This Week:

Assignments:

Codecademy: Complete the lessons (not the projects) from the Learn JavaScript module:

  1. "Iterators"

Decribe you idea and the detailed logic steps for the Interactive Website.

Read (Optional!): Chapters from Eloquent JavaScript:

Upcoming Assignments


Module Notes

In-class Exercise:

Quick Review: Change Background Color

Changing CSS with JavaScript:


Array Methods and Iterators

Two ways of declaring an array.


// Using the Array constructor
 let colors = new Array("red", "green", "blue");

// Using array literal (preferred)
 let colors = ["red", "green", "blue"];


forEach()

forEach() Demo

Upcoming Projects

Interactive Website: 5%

This assignment is designed to bring together your understanding of basic syntax, variables, conditionals, arrays, functions, and loops in JavaScript. The key objective is to create a dynamic website that allows for user interaction, resulting in changes on the webpage without altering the URL.
Suggested Ideas for Your Website

Review JavaScript and the DOM:

Traversing // get to elements on the page

Math Methods:

String Methods:

Array Methods:

Switch vs Conditionals


// Example using switch
let day = 3;

switch (day) {
 case 1:
  console.log("Monday");
  break;
 case 2:
  console.log("Tuesday");
  break;
 case 3:
  console.log("Wednesday");
  break;
 default:
  console.log("Other day");
}
// Example using else if let day = 3;

if (day === 1) {
  console.log("Monday");
} else if (day === 2) {
  console.log("Tuesday");
} else if (day === 3) {
c  onsole.log("Wednesday");
} else {
  console.log("Other day");
}