scrimba
Note at 1:31
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

Note at 1:31
AboutCommentsNotes
Note at 1:31
Expand for more info
index.js
run
preview
console
/** uncomment one of these **/
// import OpenAI from "openai" --> no
// import { HfInference } from '@huggingface/inference' --> no

/**
* 🎄 Challenge:
* 1. When clicked, the doors should open
* to reveal a festive joke.
* 🎁 hint.md for help!
**/

/*
API I ended up using: https://sahithyandev.github.io/sv443-joke-api-js-wrapper/
*/

let jokeQuestion = document.getElementById("joke-question")
let jokeAnswer = document.getElementById("joke-answer")

document.getElementById('window-container').addEventListener("click", function () {
fetch("https://v2.jokeapi.dev/joke/Christmas")
.then(response => {
if (!response.ok) {
throw new Error("Oops, try again!");
}
return response.json();
})
.then(data => {
jokeQuestion.innerText = `Q: ${data.setup}` //"setup" is a property of the API
jokeAnswer.innerText = `A: ${data.delivery}` //"delivery" is a property of the API

})
.catch(error => {
console.error('Error:', error);
});


document.querySelector('.left-door').style = "animation: left-open 0.3s forwards"
document.querySelector('.right-door').style = "animation: right-open 0.3s forwards"
document.querySelector('.joke-display').style = "animation: display-joke 0.3s forwards"
})

Console
/index.html
LIVE