Week 7: Array Methods and Iterators

To Do This Week:

Assignments:

You'll receive a provided HTML/CSS structure containing an image slider and an animated navigation menu. Your task is to write the JavaScript that makes the interface work — and to be able to explain every part of it.

Read (Optional!): Chapters from Eloquent JavaScript:

Upcoming Assignments


Module Notes

In-class Exercise:

Quick Review: Change Background Color

Changing CSS with JavaScript:



Review JavaScript and the DOM:

Traversing // get to elements on the page

Creating & Adding Elements // create new elements and add them to the page

Forms: Accessing Values

JavaScript Methods (in-built functions):

Math 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) {
  console.log("Wednesday");
} else {
  console.log("Other day");
}

Array Methods

Array Iterators

forEach() (very useful)

forEach() - w3schools
forEach() Demo

Slider/Menu Site: 5% DUE: 10/7 

You will receive a provided HTML and CSS structure containing an image slider and animated navigation menu. Your task is to write the JavaScript that makes the interface work.

This is primarily a logic and problem-solving project. You should be able to explain how each event, function, variable, and state change contributes to the slider and menu behavior. Think as an interaction designer: this is a showpiece for your portfolio.

Minimum Requirements

Logic Steps (required)

At the top of your <script>, before any code, write your numbered logic steps as a commented list. For example:

/*
  1. Select all the slides and store the current index (start at 0).
  2. Write showSlide(index): hide all slides, show the one at index.
  3. nextSlide(): add 1 to the index; if past the end, loop to 0; showSlide.
  4. prevSlide(): subtract 1; if below 0, loop to the last; showSlide.
  5. Add click listeners on the next and prev buttons.
  6. Toggle the menu open/closed on the menu button click.
*/

Workshop rhythm this week

Reference Links