buttons = document.querySelectorAll("button") buttons[0].addEventListener("click", ()=>{ const response = document.querySelector(".response") response.innerHTML = "" const xhttp = new XMLHttpRequest() xhttp.onload = function() { const jsonfile = JSON.parse(this.responseText) response.innerHTML = `${jsonfile["setup"]}
` response.innerHTML += jsonfile["delivery"] } xhttp.open("GET", "https://v2.jokeapi.dev/joke/Any?type=twopart", true) xhttp.send() }) buttons[1].addEventListener("click", ()=>{ const response = document.querySelector(".response") response.innerHTML = "" let responsetext = "" const xhttp = new XMLHttpRequest() xhttp.onload = function() { const jsonfile = JSON.parse(this.responseText) for (let i of jsonfile.jokes) { responsetext += `${i["setup"]}
` responsetext += `${i["delivery"]}` } response.innerHTML = responsetext } xhttp.open("GET", "https://v2.jokeapi.dev/joke/Any?type=twopart&amount=10", true) xhttp.send() })