scrimba
Frontend Career Path
Working with APIs
Async JS
Separate event listener callback
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

Separate event listener callback
AboutCommentsNotes
Separate event listener callback
Expand for more info
index.js
run
preview
console
/**
* Challenge: Define our anonymous callback function as a separate function, then
* pass it as the 2nd parameter to our `addEventListener`
*/

document.getElementById("new-deck").addEventListener("click", function() {
fetch("https://apis.scrimba.com/deckofcards/api/deck/new/shuffle/")
.then(res => res.json())
.then(data => console.log(data))
})
Console
3
,
/index.html
-2:53