Tag: function

Read More

FCC Zipline Series 104: Build a JavaScript Calculator | The JS Way

Today, we are going to be building a calculator app using vanilla JavaScript . No jQuery or other third party libraries/frameworks involved. I’m even going to make it more complicated by using objects and prototypical inheritance, so do not expect a quick and dirty job. Here’s a demo of what we’ll be building.

We’ll build a Calculator “class”, which will take care of the application logic. This Calculator, will have methods that we can access to pass it numbers, operations and all sorts of cool stuff that’s it.

FCC Bonfire Series 148: Caesars Cipher

FreeCodeCamp has recently added a few more challenges to the site. One of them is Caesars Cipher. This bonfire will have us write a function that mimics the ages old encryption method allegedly used by Romans back in the day.

It’s one of the simplest and oldest encryption methods, and works by replacing each character in a word or sentence with another one down the alphabet (based on a shift amount). For this exercise, we are told to use a shift of 13. Let me show you an example using the word dog and a shift of three.

  • d -> e, f, g
  • o -> p, q, r
  • g -> h, i, j

FCC Zipline Series 103: Build a Pomodoro Clock

This time, we are going to build our own Pomodoro Clock. No, this is not a Pomodoro, it’s actually a Commodore:

Commodore Norrington

The Pomodoro clock has it’s own history, which is somewhat irrelevant to us at this point, but bear with me while I take you in a journey through time and space, a time of… Nevermind, it’s really just a clock. Actually, not even a clock, but a timer that allows us to set a few parameters. Namely: Pomodoro cycle time (25 min default) and break time (5 min default).

As a note, I will mention that we are not going to be using jQuery or any other library in this process. At the end of this post, you can find links to a live version of this exercise, along with an AngularJS and React version.

FCC Zipline Series 102: Build a Random Quote Machine | The JS Way

This time, we are going to be building a Random Quote Machine. We must code a page that replicates the functionalities present here. The user stories that we must fulfil are the following:

  • As a user, I can click a button to show me a new random quote.
  • Bonus: As a user, I can press a button to tweet out a quote.

I’m going to take you through the process of setting up the JS code necessary for this app to work. If you want to give React a chance, go ahead and visit this other post, where we’ll build this same app using Facebook’s React framework.

FCC Bonfire Series 147: Friendly Date Ranges

Sad but true. Today, we’ll be tackling Friendly Date Ranges, the last bonfire in the entire FCC Bonfires Series. If you’ve made it up to this point, this next exercise shouldn’t pose much of a problem, but we’ll go through it anyway.

This time, we must write a function that given an array containing two strings that representing two dates (in ‘YYYY-MM-DD’ format) returns a human friendly date range. What the hell does that mean?

According to Free Code Camp, it’s a date range with no redundant information, in other words, if both dates are in the same year and month, only display the day range within that month etc. Keep in mind that if starting in the current year, the following year can be inferred by the reader and thus, should not be displayed. But I’ll stop babbling nonsense and show you some examples so we can get started:

['2015-10-04', '2015-10-20'] -> ['October 4th', '20th']
['2015-12-24', '2016-01-03'] -> ['December 24th', 'January 3rd']
['2020-01-21', '2021-05-25'] -> ['January 1st, 2020', 'May 25th, 2021'];