In this repo, we will be working through increasing knowledge in JS array methods by refactoring a Black Excellence Reference app.
Array methods are functions that are built-in to JavaScript that can be applied to arrays.
Each method has a unique function that performs a change or calculation to our array and saves us from writing common functions from scratch.
It is important to FIRST identify the problem you are trying to solve and then seeing if there is an array method that can help you solve that problem.
You can do a google search for JS array methods
to find what is available to you.
We are about to learn about a few array methods and then you are going to try some yourself.
As we code along, make sure to take notes in the issue tickets that were created when you copied the repo so that you have something to come back to and reference at a later time.
I will NOT be reviewing all the methods, and I will not go deeply into the algorithms. That is up to you and your learning as a software engineer.
You will notice in the code, there are several directories with elements that make up the app. You are free to review those AFTER our class session, but they are not the focus of this learning.
For this exercise, we will be working in the scripts
directory.
Attribute | Type |
---|---|
id | number |
title | string |
author | string |
price | number |
image | string |
youTubeId | string |
type | string |
description | string |
externalLink | string |
inCart | boolean |
const referenceList = [
{
id: 1,
title: "HBCU Info",
author: "Author Name",
price: 45.00,
image: "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f.jpg",
youTubeId: "",
type: "info",
description: "Historically black colleges and universities (HBCUs) are institutions of higher education.",
externalLink: "https://en.wikipedia.org/wiki/Historically_black_colleges_and_universities",
inCart: false
}
]
includes()
- string methodfilter()
map()
forEach()
reduce()
findIndex()
some()
sort()