Øvelse 14: Tilpas passets profil

Opgavebeskrivelse

Hent style og color fra select-felterne og goal fra textarea. Brug dem til at tilpasse event-passets farve, profil og målsætning.

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 profileOutput = document.querySelector(".pass-profile");
  const goalOutput = document.querySelector(".goal-output");
  const params = new URLSearchParams(location.search);

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

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

  chipOne.textContent = interests[0] || "Ingen interesser valgt";
  chipTwo.textContent = interests[1] || "";
  chipThree.textContent = interests[2] || "";

  // Hent style, color og goal
  // Brug color som eventPass.dataset.color
  // Vis goal, og vælg en profiltekst ud fra style
  
}
/

Hints

const style = params.get("style");
const color = params.get("color");
const goal = params.get("goal");

eventPass.dataset.color = color;
goalOutput.textContent = goal;

if (style === "tech") {
  profileOutput.textContent = "Code explorer";
} else if (style === "editorial") {
  profileOutput.textContent = "Visual thinker";
} else {
  profileOutput.textContent = "Creative builder";
}

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?