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

Demonstrate the use of chained if else.


<html>
<body>

<script>

bananas = 22

if (bananas == 6)
{
	alert("We have six bananas.")
}
else if (bananas == 10)
{
	alert("We have ten bananas.")
}
else
{
	alert("We have another quantity of bananas.")
}

</script>

</body>
</html>
In the exemple above, we will fall into "We have another quantity of bananas.", because the first two ifs will evaluate to false. Try changing the value of bananas (to 6 or 10), to enter the first or second code blocks.

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