Gerardo Castro 0 Posted December 8, 2020 Report Share Posted December 8, 2020 (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 by Gerardo Castro Link to post Share on other sites
Zex 11 Posted December 8, 2020 Report Share Posted December 8, 2020 (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 by Zex 1 Report Link to post Share on other sites
Gerardo Castro 0 Posted December 8, 2020 Author Report Share Posted December 8, 2020 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 post Share on other sites
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