freeCodeCamp
freeCodeCamp copied to clipboard
Add review lessons for arrays in pyramid project
Describe the Issue
A few of the array lessons pop up frequently on the forum when it comes to the pyramid project. So it would be good for campers to review the array basics before moving onto the next set of new information so they will be able to retain it better and feel more comfortable.
Note Step numbers are subject to change since this course is still in beta. But we should add two new steps after this one here
https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f09a2694b59c3a10ee304.md
first new review step
description
In the last few steps, you learned all about working with arrays. Now it is time to review what you have learned so you can apply this knowledge to the pyramid generator project.
In this step, you will need to do the following:
- Create a variable called `cities` and assign it an array of three strings: `"London",` `"New York"`, `"Mumbai"`
- On a new line, log the entire array to the console
- On a new line, update the last element of the array to the string `"Mexico City"`
- On a new line, log the entire array to the console
When done correctly, you should see this output in the console
```js
[ 'London', 'New York', 'Mumbai' ]
[ 'London', 'New York', 'Mexico City' ]
```
hints and tests
the hints and tests should be granular like this
- You should use
let
to create acities
variable. - You should assign an array of strings to the
cities
variable. The strings should be"London"
,"New York"
,"Mumbai"
. - You should use
console.log()
to log the entirecities
array to the console. - You should update the last element of the
cities
array to the string"Mexico City"
. Remember that you can access the last element of an array usingarray[array.length - 1]
. - You should have two
console.log(cities)
statements in your code.
starting seed code
```js
let character = 'Hello';
let count = 8;
let rows = ["Naomi", "Quincy", "CamperChan"];
--fcc-editable-region--
--fcc-editable-region--
console.log(rows);
```
second new review step
description
Now you are ready to move onto the next set of array lessons.
Remove all of your code from the previous step.
hints
the tests and hints should be granular here like this:
You should not have a `cities` array in your code.
You should not have a `console.log(cities)` statement in your code.
You should not have a `cities[cities.length - 1] = "Mexico City"` statement in your code.
starting seed code
```js
let character = 'Hello';
let count = 8;
let rows = ["Naomi", "Quincy", "CamperChan"];
--fcc-editable-region--
let cities = ["London", "New York", "Mumbai"]
console.log(cities)
cities[cities.length - 1] = "Mexico City"
console.log(cities)
--fcc-editable-region--
console.log(rows);
```
Affected Page
multiple
Your code
see explanation above
Expected behavior
see explanation above
Screenshots
No response
System
- Device: [e.g. iPhone 6, Laptop]
- OS: [e.g. iOS 14, Windows 10, Ubuntu 20.04]
- Browser: [e.g. Chrome, Safari]
- Version: [e.g. 22]
Additional context
No response