Paracetamol.js馃拪| #114: Explica este c贸digo JavaScript



Explica este c贸digo JavaScript




Dificultad: Intermedio

const randomNumber = () => {
  return new Promise((resolve, reject) => {
    let random = Math.ground(Math.random() * 10) + 1;
    if(random >= 5){
      resolve(`Bien... ${random}`)
    }else{
      reject(`Mal... ${random}`)
    }
  })
}

randomNumber()
  .then(x => console.log(x))
  .catch((error) => console.log(error))
Enter fullscreen mode

Exit fullscreen mode

A. Dependiendo del valor de random imprimir谩 Bien o Mal
B. Promise { <pending> }
C. Promise { <fulfill> }
D. Ninguna de la anteriores

Respuesta en el primer comentario.


Add a Comment

Your email address will not be published. Required fields are marked *