Gabriele Ferro Home

Following the routine.

As I decided a few days ago, I follow a specific routine to avoid wasting time with futile activities.

This will be my routine for a few weeks:

  • Write code for OpenClassRooms projects;
  • Review the basics of JavaScript and advanced concepts with Codecademy;
  • Start freeCodeCamp JavaScript projects in parallel to get the certificate.

Day 57: 7 Octobre 2020

**Today’s Progress:**

I continued to write code for the fifth OpenClassRooms project and added a video in the Product Detail page

I used this technique to create an overlay on a background video.

Then I completed the freeCodeCamp challenge of the Roman numeral converter.

The function takes the number, converts it into a string and creates an array with the split function.

Each element of the tmp array will contain one digit of our starting number.

This will give us access to some functions useful to manipulate the strings.

Then we save the length of our string, which is the number of digits of our number.

Once we know how many digits our number is composed we can scroll through them with a for cycle.

Then with the pop() method we extract the first digit of our array at each for cycle, then in order we will have units, tens, hundreds and thousands.

Knowing that each index of the for cycle corresponds to a specific position of our number, we can compare it case by case (with the switch) and insert the corresponding string in the output array we had previously declared.

We will use unshift in this case to insert these strings at the beginning of our output array.

In the case of thousands, the value is enough to hang as many M for how many thousands are present in our initial number.

Finally, we print the result on screen before returning it (I often do this for simplicity during debugging).

Before we print it and return it, we join the elements of the array and finally convert it into a string.

As planned, I reviewed JavaScript with Codecademy Go and did some quizzes about:

  • Math.floor()
  • Template Literals
  • else if clause
  • Break keyword
  • Truthy & Falsy values
  • Async & await


I have to resist the temptation to play Genshin Impact for 10 hours a day.

I would be able to play it even 16 hours a day since I'm on vacation >_>

**Link to tweet:**

[twitter-follow screen_name='20Gabriele20']

February 2024


Gabriele Ferro Home
Copyright © Ferro Gabriele. All rights reserved.