Øvelse 13: Vis flere checkbox-værdier

Opgavebeskrivelse

Flere checkboxes deler name=“interest” og giver gentagne query-parametre. Hent dem med getAll(), og brug arrayets pladser 0, 1 og 2 til at vise værdierne i hver sin chip.

const eventPass = document.querySelector(".event-pass");

if (eventPass) {
  const nicknameOutput = document.querySelector(".nickname");
  const reasonOutput = document.querySelector(".reason-output");
  const hypeLevel = document.querySelector(".hype-level");
  const chipOne = document.querySelector(".chip-one");
  const chipTwo = document.querySelector(".chip-two");
  const chipThree = document.querySelector(".chip-three");
  const params = new URLSearchParams(location.search);

  const nickname = params.get("nickname");
  const reason = params.get("reason");
  const hypeValue = Number(params.get("hype"));

  nicknameOutput.textContent = nickname;
  reasonOutput.textContent = reason;
  if (hypeValue >= 75) {
    hypeLevel.textContent = "Høj";
  } else if (hypeValue >= 40) {
    hypeLevel.textContent = "Middel";
  } else {
    hypeLevel.textContent = "Lav";
  }

  // Hent alle interest-værdier, og vis dem i hver sin chip
  
}
/

Hints

const interests = params.getAll("interest");
chipOne.textContent = interests[0] || "Ingen interesser valgt";
chipTwo.textContent = interests[1] || "";
chipThree.textContent = interests[2] || "";

Skriv mindst to tegn

Brug en fuld URL, fx https://example.com

Skriv en gyldig URL

Hvad håber du at få med hjem?

Vælg én mulighed

Du skal acceptere retningslinjerne

Hvad interesserer dig?