CPNT 262 Day 9 - Looping with objects

Housekeeping

Trophies of the Day


1. Spoiler Demos


2. Local images

While Lorem Picsum is a wonderful service for inserting placeholder images, it's not a practical solution for a production website.

In this session, you will refactor yesterday's Lorem Picsum gallery to use local images instead of placeholder links.

Materials

Activity: Refactor for local images

  • Replace the placeholder links in the Lorem Picsum Gallery with local image links. For example,

    Instead of this:

    <img src="https://picsum.photos/id/237/300/300" alt="...">

    Use host your images locally like this:

    <img src="images/md/237.jpg" alt="...">

3. Arrays of objects

Materials

Activities


4. Stretch: for loops

Materials

Activities

  • FizzBuzz: Using conditional logic and a for loop, print a series of numbers from 1 to 100 such that:

    • if the number is divisible by 3, print 'Fizz';
    • if the number is divisible by 5, print 'Buzz';
    • if the number is divisible by both 3 and 5, print 'FizzBuzz';
    • otherwise, print the number.
  • Using a for loop and your favourite mocking Sponge Bob meme, create a function that will turn a phrase like this:

    "Can I get some extra credit?"

    To sticky caps, like this:

    "cAn i GEt SomE eXtRa creDiT?"


Prep

Loops

Objects

Strings