Bem-vindo ao JavaScript Tutorial
Previous topic/Tópico anterior
Next topic/Próximo tópico
05 - if else conditional expressions

Use the else, when if is not true.


<html>
<body>

<script>

bananas = 22

if (bananas == 6)
{
	alert("It's true. We have a half dozen of bananas.")
}
else
{
	alert("It's not true. We have another quantity of bananas.")
}

</script>

</body>
</html>
In this example we are using the if else.
Explanation: If (if) the number of bananas is equal to 6, do alert("It's true. We have a half dozen of bananas."). Else (else), do alert("It's not true. We have another quantity of bananas.").
So simple, isn't it?

Previous topic/Tópico anterior
Next topic/Próximo tópico
[ Voltar ]


© 2005 JavaScript Tutorial Brasil
Proibida a cópia ou distribuição integral ou parcial não-autorizada
Unauthorized integral or partial distribution or reproduction is forbidden
Patrocínio - Assistência Técnica de Calculadoras HP CSCenter