Javascript
JavaScript Fundamentals -- Arrays in JavaScript

Exercise 1 Review

PRO
Outline

Here is a possible solution to this exercise:

// map and filter
const courses = [
  { name: 'JavaScript Fundamentals' },
  { name: 'Angular CLI Basics' },
  { name: 'Deploying Apps to Netlify' }
]

// 1. Use the map method to create an array of course names (strings only) from the courses array
const courseNames = courses.map(course => course.name);
console.log(courseNames);

// 2. Use the filter method to create an array from the courses array where the only item is the one with a name of 'JavaScript Fundamentals'
const filtered = courses.filter(course => course.name === 'JavaScript Fundamentals');
console.log(filtered);

You can view the solution on StackBlitz.

 

I finished! On to the next chapter