Mike Nolan

To improve is to change; to be perfect is to change often. -Winston Churchill

Day 23- JS Loops

02 Sep 2025

More loop lab focus today and it certainly not getting any easier, is frustrating as in the end it is ending up a small amount of code but I know that with each iteration I am learning, its just trying to embed that learning as I go.

For example this is the last Lab - to build a profile lookup from a JSON object. I tried using a for in loop first of all without realising that is more for objects rather than an array, so tried it with a for or loop and couldnt quite get that to how I wanted it either before settling with a while loop. I then had an issue with getting the contracts[i][prop] to return as I had it as contracts[i].prop so need some further reading on that as when running my code through chatGPT it was telling me it was trying to literally read the property “prop” which doesnt exist.

function lookUpProfile(name, prop) {
  let i = 0;
  //loops through the contacts array
  while (i < contacts.length) {
    //If the name given matches the firstName of the contact being checked and that contact has the property being searched for then return the value of that property
    if (name === contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    } else if (name === contacts[i].firstName) {
      return "No such property";
    }
    i++;
  }
  return "No such contact";
}

FreeCodeCamp Modules

  • HTML - 214 out of 214 Steps Completed
  • CSS - 1156 out of 1156 Steps Completed
  • JavaScript - 235 out of 918 Steps Completed

Front End Mentor

  • 7 Challenges Completed

What have I completed today :white_check_mark:

  • FCC Loops

    • Lab: Implement the Chunky Monkey Algorithm
    • Lab: Build a String Repeating Function
    • Lab: Build a Profile Lookup
    • Review: JavaScript Loops Review
    • Quiz: JavaScript Loops Quiz
  • JavaScript Fundamentals Review

    • Lecture: Working with Types and Objects
    • Lecture: Working with Arrays, Variables and Naming Practices
    • Lecture: Working with Code Quality and Execution Concepts

What is next on the list :pencil2:

  • JavaScript Fundamentals Review
    • Lab: Build the Largest Number Finder
    • Lab: Build a First Element Finder
    • Lab: Implement the Slice and Splice Algorithm
    • Lab: Build a Pyramid Generator
    • Lab: Build a Gradebook App
    • Lecture: The var Keyword and Hoisting
    • Lab: Build an Inventory Management System
    • Lecture: Understanding Modules, Imports and Exports
    • Lab: Build a Password Generator App
    • Lab: Design a Sum All Numbers Algorithm
    • Lab: Implement a HTML Entity Converter
    • Review: JavaScript Fundamentals Review
    • Quiz: JavaScript Fundamentals Quiz

What have I been reading? :books:

  • MDN, Stackoverflow and W3Schools
Mike