Day 60 / 100 Days of Code: Deeper into JavaScript
Jacob Stern

Jacob Stern @jacobdavidstern

About: 6/29/2024 starts my 100 Day of Code challenge with Codecademy. Let's go!

Location:
Phoenix, AZ, USA
Joined:
Jun 29, 2024

Day 60 / 100 Days of Code: Deeper into JavaScript

Publish Date: Aug 30 '24
1 0

Thu, August 29, 2024

Today, I continued my journey through Codecademy’s Full Stack Engineer path. One thing I’ve noticed is that while the syllabus provides a solid framework, there are often additional layers of learning beneath and between assignments.

In the Number Guessing Game Project, the task was to write well-defined control flow functions. This went quite quickly for me. From what I’ve seen on the Codecademy forums, only about 5% of students used arrow functions for this project. I opted for arrow functions because they improve concision and readability, especially for one-liners. One important thing to remember with arrow functions is that they cannot be hoisted, so their order of declaration matters. Otherwise, there were no surprises. Here’s my implementation:

let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;

const generateTarget = () => Math.floor(Math.random() * 10);

const getAbsoluteDistance = (number1, number2) => Math.abs(number2 - number1);

const updateScore = winner => winner === 'human' ? humanScore++ : computerScore++;

const compareGuesses = (humanGuess, computerGuess, secretTarget) => 
  getAbsoluteDistance(humanGuess, secretTarget) <= getAbsoluteDistance(computerGuess, secretTarget);

const advanceRound = () => currentRoundNumber++;
Enter fullscreen mode Exit fullscreen mode

After wrapping up the first JavaScript Syntax lesson, I jumped right into the second lesson and completed the first assignment on Arrays. Learning that arrays declared as const are mutable was a mind-blowing revelation! With Arrays down, I’m now moving on to Loops and then Objects. I’m really enjoying how Codecademy provides resources and then lets us explore on our own.

Comments 0 total

    Add comment