Gerardo Castro Posted December 8, 2020 at 07:06 PM Report Share #620595 Posted December 8, 2020 at 07:06 PM (edited) Boa tarde a todos, Precisava de ajuda com o seguinte exercício, pois estou completamente bloqueado: "Declare a variable named countdown and assign it the value of 10. In a while loop, decrement the value of countdown once for every iteration and print it. Once countdown hits 0 print 'Blastoff' to the console." Até agora estou aqui: var countdown = 10;{ while (countdown > 0) { console.log(countdown); countdown = countdown - 1; } console.log("Blastoff!"); } Output >>>>Code is incorrect The first line in your while's block should decrement the value of the variable countdown 10 9 8 7 6 5 4 3 2 1 Blastoff! Edited December 8, 2020 at 07:21 PM by Gerardo Castro Link to comment Share on other sites More sharing options...
Zex Posted December 8, 2020 at 07:38 PM Report Share #620596 Posted December 8, 2020 at 07:38 PM (edited) O programa funciona mas o verificador quer exatamente como no enunciado. O enunciado diz: "decrementar e imprimir". Deves trocar a ordem das linhas para decrementar aparecer antes que imprimir. No fim Blastoff não deve ter "!" a não ser que esteja no enunciado. Edited December 8, 2020 at 07:40 PM by Zex 1 Report Link to comment Share on other sites More sharing options...
Gerardo Castro Posted December 8, 2020 at 09:51 PM Author Report Share #620600 Posted December 8, 2020 at 09:51 PM Muito muito obrigado, já são muitas horas seguidas nisto e de facto há coisas básicas que escapam. var countdown = 10; while (countdown > 0){ countdown--; console.log(countdown); } console.log("Blastoff"); Citação Output >>>>Code is correct 9 8 7 6 5 4 3 2 1 0 Blastoff Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now