codex-lv2-may-2025

Level Navigation: 0 Current Level: 1 2 3 4 5


Lesson: Setup and Look & Guess

🎯 Objective

Set up your project environment and complete the initial “Look and Guess” activity to understand basic POJO structure.


âś… Setup Step: Prepare Your Project

In the terminal:

  1. Navigate to where you want your project folder:
cd path/to/your/projects
  1. Create a new folder and enter it:
mkdir pojo-practice
cd pojo-practice
  1. Initialize a Git repository:
git init
  1. Create a script file:
touch script.js

The file script.js is the only file you will need for this lesson. You will copy and paste the starter code from the lessons into this file, as you progress in the level. By the end of the Lesson, you will have all the starter code pasted in. You will also write your code in this file. Note: This file will get long!

  1. Create a new repository on GitHub called:
pojopractice
  1. Follow GitHub’s instructions to connect your local repository to GitHub.

âś… Step 1: Look and Guess

Instructions

  1. Copy this code into script.js:
const pet = {
    "name": "Buddy",
    "species": "Dog",
    "age": 5
};

console.log(pet.name);
console.log(pet.species);
console.log(pet.age);

pet.age = 6;
console.log(pet.age);

// TODO: What do you think each console.log will print?
  1. Make a guess. Write your predictions as a comment in the file:
// I guess it will print: ...
  1. Run the file in the terminal:
node script.js
Click to see the answer

Expected output:

Buddy
Dog
5
6
    

Explanation:

  • console.log(pet.name) prints: Buddy
  • console.log(pet.species) prints: Dog
  • console.log(pet.age) prints: 5 (original value)
  • pet.age = 6 updates the age property to 6
  • console.log(pet.age) prints: 6 (updated value)

âś… ACP

git add script.js
git commit -m "Step 1 completed - Look and Guess"
git push

âś… Summary

You practiced:




Level Navigation: 0 Current Level: 1 2 3 4 5