2
I have the following code:
var age = parseInt(prompt('Digite sua idade: '));
function verificar(age){
return new Promise(function(resolve,reject){
if(age > 18){
resolve(console.log('DEU CERTO'))
}else{
reject(console.log('MENOR'))
}
})
}
verificar()
.then(
function(){
console.log('Maior de idade')
}
)
.catch(
function(){
console.log('Menor de idade')
}
)
I’ve already converted the prompt()
for whole type using the parseInt()
. The problem is that even typing an age greater than 18, it keeps falling into the .catch()
and returning that the user is under age. Someone knows how to solve?
But you are not passing any parameter when you invoke the function
verificar()
. Shouldn’t beverificar(age)
?– Andre
@user140828 was just that, I didn’t notice rs. Thank you.
– Danúbio Vieira Lima
some response helped you?
– novic