Day 68: 23 October 2020
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
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.
10because all odd Fibonacci numbers less than or equal to
10are 1, 1, 3, and 5.
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
forloops with an iterator variable that increments or decrements
- How to use a
forloop to iterate through an array
- A nested
forloop is a loop inside another loop
whileloops allow for different types of stopping conditions
- Stopping conditions are crucial for avoiding infinite loops.
do...whileloops run code at least once— only checking the stopping condition after the first execution
breakkeyword allows programs to leave a loop during the execution of its block
Review & Cheatsheet
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
- 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:**