-1
DOUBT: How to make an IF ELSE with javascript to display a text (Ex: Approved) when locating a given word (Ex: Green). My current code is this below, but it’s not working and I can’t find the problem. I’m a beginner with Javascript, so if anyone knows how to help me thank you!
var status_atual = 'Azul'; //
if (status_atual = "Verde") {
return 'Aprovado';
} else if (status_atual = "Vermelho") {
return 'Reprovado';
} else if (status_atual = "Amarelo") {
return 'Incompleto';
} else if (status_atual = "Azul") {
return 'Novo';
} else {
return 'Cor e status não identificados!';
}
I needed to have the result displayed in the table, just as it is done in PHP with the echo function, so for example:
<?php
$status_atual = 'Azul';
if ($status_atual = 'Verde') {
echo 'Aprovado';
} else if ($status_atual = 'Vermelho') {
echo 'Reprovado';
} else if ($status_atual = 'Amarelo') {
echo 'Incompleto';
} else if ($status_atual = 'Azul') {
echo 'Novo';
} else {
echo 'Cor e status não identificados!';
}
?>
Example of the IF ELSE result being displayed in the table:
Note that both JS and PHP code have problems.
– tvdias
Comparison operator is
==
or===
. The=
is itself an allocation operator.– Wallace Maxters