DEV Community

Jacob Stern
Jacob Stern

Posted on

1

Day 60 / 100 Days of Code: Deeper into JavaScript

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.

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay