Last active
May 11, 2023 23:12
-
-
Save jlescalonap/99964a0400f39dd350b8ebe44ed8dd2a to your computer and use it in GitHub Desktop.
Correções Geovanna
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var backgroundColor = ""; // É necessario inicializar as variaveis | |
var color = ""; // É necessario inicializar as variaveis | |
var opt = 0; // É necessario inicializar as variaveis | |
/* | |
Se lembre sempre inicializar as variaveis em javascript, | |
elas devem ser inicializadas respeitando a tipagem, ou seja, | |
se a variavel é pra receber uma string, você inicializa com '' ou "". | |
se for um numero inicializa com 0 ou o valor inicial que deseja que ela tenha. | |
*/ | |
function GetOption(option) { | |
switch (option) { | |
case 1: | |
opt = 1; | |
backgroundColor = document.getElementById("I"); | |
backgroundColor.style.backgroundColor = "hsl(25, 97%, 53%)"; | |
color = document.getElementById("I"); | |
color.style.color = "white"; | |
break; | |
case 2: | |
opt = 2; | |
backgroundColor = document.getElementById("II"); | |
backgroundColor.style.backgroundColor = "hsl(25, 97%, 53%)"; | |
color = document.getElementById("II"); | |
color.style.color = "white"; | |
break; | |
case 3: | |
opt = 3; | |
backgroundColor = document.getElementById("III"); | |
backgroundColor.style.backgroundColor = "hsl(25, 97%, 53%)"; | |
color = document.getElementById("III"); | |
color.style.color = "white"; | |
break; | |
case 4: | |
opt = 4; | |
backgroundColor = document.getElementById("IV"); | |
backgroundColor.style.backgroundColor = "hsl(25, 97%, 53%)"; | |
color = document.getElementById("IV"); | |
color.style.color = "white"; | |
break; | |
case 5: | |
opt = 5; | |
backgroundColor = document.getElementById("V"); | |
backgroundColor.style.backgroundColor = "hsl(25, 97%, 53%)"; | |
color = document.getElementById("V"); | |
color.style.color = "white"; | |
break; | |
} | |
return opt; | |
} | |
// var selectedOpt = GetOption(opt); < -- Essa função não é necessaria! | |
function SubmitResult() { | |
var containerArea = document.getElementById("container"); | |
containerArea.innerText = ""; | |
const img = document.createElement("img"); | |
img.src = "images/illustration-thank-you.svg"; | |
containerArea.appendChild(img); | |
var optionArea = document.createElement("p"); | |
optionArea.innerText = `You selected ${opt} out of 5`; // É mais direto que aqui o valor seja tomado da variavel opt | |
containerArea.appendChild(optionArea); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment