Gabriele Ferro Home

Fibonacci Challenge on freeCodeCamp

Day 68: 23 October 2020

**Today’s Progress:**

Passed the Intermediate Algorithm Scripting Challenge on freeCodeCamp: Sum All Odd Fibonacci Numbers

Given a positive integer num, return the sum of all odd Fibonacci numbers that are less than or equal to num.

The first two numbers in the Fibonacci sequence are 1 and 1. Every additional number in the sequence is the sum of the two previous numbers. The first six numbers of the Fibonacci sequence are 1, 1, 2, 3, 5 and 8.

For example, sumFibs(10) should return 10 because all odd Fibonacci numbers less than or equal to 10 are 1, 1, 3, and 5.

I had recently read this very interesting article that compares three methods to create the Fibonacci sequence. So I readjusted the code of the first implementation according to my needs.

Progress on Codecademy


Review & Cheatsheet

Great job! In this lesson, we learned how to write cleaner code with loops. You now know:

  • Loops perform repetitive actions so we don’t have to code that process manually every time.
  • How to write for loops with an iterator variable that increments or decrements
  • How to use a for loop to iterate through an array
  • A nested for loop is a loop inside another loop
  • while loops allow for different types of stopping conditions
  • Stopping conditions are crucial for avoiding infinite loops.
  • do...while loops run code at least once— only checking the stopping condition after the first execution
  • The break keyword allows programs to leave a loop during the execution of its block


Review & Cheatsheet

Great job! By thinking about functions as data and learning about higher-order functions, you’ve taken important steps in being able to write clean, modular code and take advantage of JavaScript’s flexibility.

Let’s review what we learned in this lesson:

  • Abstraction allows us to write complicated code in a way that’s easy to reuse, debug, and understand for human readers
  • We can work with functions the same way we would any other type of data including reassigning them to new variables
  • JavaScript functions are first-class objects, so they have properties and methods like any object
  • Functions can be passed into other functions as parameters
  • A higher-order function is a function that either accepts functions as parameters, returns a function, or both


I tried to write the solution of another freeCodeCamp challenge but it doesn't work for the moment.

I need to prepare slides to use as presentation media for my fifth OpenClassRooms project.

I will use Slides Carnival.

I also need to start studying these courses (in French) that I will need for the sixth OpenClassRooms project:

**Link to tweet:**

[twitter-follow screen_name='20Gabriele20']

July 2024


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