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 your 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:



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

Interactive Website: 5% DUE: Thursday Feb 19 

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. *In all projects in this class you will include in the source code the natural language steps of your script.Add your commented out ( /*…*/ ) steps in a numbered list inside the <script> tag. 

Suggested Ideas for Your Website

JS Mentor

JS Mentor is a Custom GPT created for this class. Think of it like your personal JavaScript tutor — it helps you learn by guiding you through problems step by step.

Here’s how to get the most out of it:

  1. Describe Your Idea
    Start by explaining what you want to build or what you're trying to solve — even in plain English. JS Mentor will help you turn that into code.
  2. Break It Down
    JS Mentor will ask you to think through your idea logically: What should happen first? Then what? You’ll write these logic steps in your own words before jumping into code.
  3. Code One Step at a Time
    Once your logic is clear, JS Mentor will help you write one JavaScript statement at a time. You’ll write the code, and it’ll give hints, corrections, or next steps if you get stuck.
  4. Ask for Help
    If you’re stuck, say so! You can ask for a hint, a mini quiz, or even a code example if needed.
  5. Learn by Doing
    Don’t worry about mistakes — JS Mentor is here to help you learn by trying. The more you engage and experiment, the more confident you’ll get.