Bem-vindo ao JavaScript Tutorial
Previous topic/Tópico anterior
Next topic/Próximo tópico
10 - do while looping expressions

Use do while when you want that a code block repeat n times, but the block itself is executed before the first conditional check.


<html>
<body>

<script>

number = 0

do
{
	number++
}
while (number < 10)

alert(number)

</script>

</body>
</html>
The difference of having a do before the while, is that it will execute the code first, THEN evaluate the conditional to check if it must continue looping through the code block.

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