0
I decided to make a project of calculation of average school with conditional, where I can perform the calculation n
times, or finish if you wish.
No replit.com is running, but VS Code is giving error
undefined prompt
Where would be the mistake?
console.log('####################################')
console.log('####### Média do Aluno 2021! #######')
console.log('####################################')
let dados = true
while (dados = prompt('\nDeseja calcular a média do aluno? (s) para Sim (n) para Não: ')) {
if (dados === 's') {
let nome = prompt(`\nQual o nome do aluno? `)
let n1 = parseFloat(prompt(`\nQual a primeira nota? `))
let n2 = parseFloat(prompt(`Qual a segunda nota? `))
let n3 = parseFloat(prompt(`Qual a terceira nota? `))
let n4 = parseFloat(prompt(`Qual a quarta nota? `))
let media = (n1 + n2 + n3 + n4) / 4
console.log(`\nA média do aluno ${nome} é ${media}`)
if (media >= 7){
console.log(`\nAluno ${nome} [aprovado!]`)
}
else {
console.log(`\nAluno ${nome} [reprovado!]`)
}
}
else {
console.log('\n##############################################\n### Obrigado por utilizar o nosso sistema! ###\n##############################################')
break
}
}
window.prompt(....)
resolves?– Cmte Cardeal
I could not. Here was error. :/
– SirMarcius
prompt
withwhile
is not a good idea, should read the value for a variable and use the variable inwhile
– Ricardo Pontual
Without wanting to abuse, could you give an example? it would be of great help to understand where I’m going wrong. I thank you already.
– SirMarcius
yes @Sirmarcius, can for example do so:
while (true) { var dados = prompt(....); if (dados == "N") break; .... resto do código ... }
– Ricardo Pontual