Day 66: 19 October 2020
I had very little time to devote to programming so I preferred to continue the Codecademy path rather than bang my head with the freeCodeCamp challenges I have left.
Having finished the fifth OpenClassRooms project I am in a limbo where I have to present the project but I also have to start studying the courses for the next one.
Review & Cheatsheet
In this lesson, you learned about scope and how it impacts the accessibility of different variables.
Let’s review the following terms:
- Scope is the idea in programming that some variables are accessible/inaccessible from other parts of the program.
- Blocks are statements that exist within curly braces
- Global scope refers to the context within which variables are accessible to every part of the program.
- Global variables are variables that exist within global scope.
- Block scope refers to the context within which variables that are accessible only within the block they are defined.
- Local variables are variables that exist within block scope.
- Global namespace is the space in our code that contains globally scoped information.
- Scope pollution is when too many variables exist in a namespace or variable names are reused.
As you continue your coding journey, remember to use best practices when declaring your variables! Scoping your variables tightly will ensure that your code has clean, organized, and modular logic.
Review Arrays & Cheatsheet
Nice work! In this lesson, we learned these concepts regarding arrays:
- Arrays are created with brackets
- Each item inside of an array is at a numbered position, or index, starting at
- We can access one item in an array using its index, with syntax like:
- We can also change an item in an array using its index, with syntax like
myArray = 'new string';
- Arrays have a
lengthproperty, which allows you to see how many items are in an array.
- Arrays have their own methods, including
.pop(), which add and remove items from an array, respectively.
- Arrays have many methods that perform different tasks, such as
.shift(), you can find documentation at the Mozilla Developer Network website.
- Some built-in methods are mutating, meaning the method will change the array, while others are not mutating. You can always check the documentation.
- Variables that contain arrays can be declared with
const. Even when declared with
const, arrays are still mutable. However, a variable declared with
constcannot be reassigned.
- Arrays mutated inside of a function will keep that change even outside the function.
- Arrays can be nested inside other arrays.
- To access elements in nested arrays chain indices using bracket notation.
Learning how to work with and manipulate arrays will help you work with chunks of data!
I've been working all day thinking about how to implement the prime numbers challenge and the fibonacci challenge.
I remember that at university, to find the first n prime numbers I used the Eratosthenes sieve, but I have to find the courage and strength to write the algorithm.
**Link to tweet:**