document.getElementById("new-deck").addEventListener("click", handleClick)
document.getElementById("draw-cards").addEventListener("click", () => {
fetch(`https://apis.scrimba.com/deckofcards/api/deck/${deckId}/draw/?count=2`)
.then(res => res.json())
.then(data => {
console.log(data.cards)
document.getElementById("cards").innerHTML = `
<img src=${data.cards[0].image} class="card" />
<img src=${data.cards[1].image} class="card" />
`
})
})
/**
* Challenge:
*
* Create a spot in the HTML for the cards to be placed in.
* Typical playing cards have a 5:7 ratio (width-to-height).
*/
let deckId
function handleClick() {
fetch("https://apis.scrimba.com/deckofcards/api/deck/new/shuffle/")
.then(res => res.json())
.then(data => {
console.log(data)
deckId = data.deck_id
})
}