This content originally appeared on DEV Community and was authored by Cristian Fernando
Explica este código JavaScript
Dificultad: Intermedio
const randomNumber = () => {
return new Promise((resolve, reject) => {
let random = Math.floor(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))
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.
This content originally appeared on DEV Community and was authored by Cristian Fernando
Cristian Fernando | Sciencx (2022-05-11T14:45:45+00:00) Paracetamol.js💊| #114: Explica este código JavaScript. Retrieved from https://www.scien.cx/2022/05/11/paracetamol-js%f0%9f%92%8a-114-explica-este-codigo-javascript/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.