scrimba
Frontend Career Path
Working with APIs
Async JS
Callbacks - revisiting array.filter
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Callbacks - revisiting array.filter
AboutCommentsNotes
Callbacks - revisiting array.filter
Expand for more info
index.js
run
preview
console
function handleClick() {
fetch("https://apis.scrimba.com/deckofcards/api/deck/new/shuffle/")
.then(res => res.json())
.then(data => console.log(data))
}

document.getElementById("new-deck").addEventListener("click", handleClick)

// function callback() {
// console.log("I finally ran!")
// }

// setTimeout(callback, 2000)

/**
* Challenge:
*
* Part 1: Given the array of objects below, create a new array with the `.filter()` array method that contains only the objects where "hasPet" is true
*
*
* Part 2: Move the anonymous in-line function to its own, named function
*/

const people = [
{ name: "Jack", hasPet: true },
{ name: "Jill", hasPet: false },
{ name: "Alice", hasPet: true },
{ name: "Bob", hasPet: false },
]
Console
/index.html
-7:42