Last active
October 9, 2022 19:18
-
-
Save geraldotech/6e1d81eff46501dc1014bd499ab20974 to your computer and use it in GitHub Desktop.
Calculadora notas laço while - JavaScript - Video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let [cont,sum,qt] = [1,0,2]; //contador, soma e quantidade de notas | |
while(cont <= qt){ | |
const notas = +prompt(`Digite a nota ${cont}`); | |
if(notas > 10) { alert('nota invalida!'); break; } // verifica se a nota for maior que 10 cancela a operacao | |
sum += (notas) //faz a soma | |
document.write(`Nota ${cont} => ${notas}`); | |
document.write('<br>'); | |
cont++; | |
} | |
let media = sum /qt; | |
document.write(`A soma => ${sum}`); | |
document.write('<br>'); | |
document.write(`A media => ${media}`); | |
document.write('<br>'); | |
media >=6 ? document.write("Situação: APROVADO!") : document.write("Situação: REPROVADO!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment