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.floor(Math.random() * 10) + 1;
if(random >= 5){
resolve(`…


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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Paracetamol.js💊| #114: Explica este código JavaScript." Cristian Fernando | Sciencx - Wednesday May 11, 2022, https://www.scien.cx/2022/05/11/paracetamol-js%f0%9f%92%8a-114-explica-este-codigo-javascript/
HARVARD
Cristian Fernando | Sciencx Wednesday May 11, 2022 » Paracetamol.js💊| #114: Explica este código JavaScript., viewed ,<https://www.scien.cx/2022/05/11/paracetamol-js%f0%9f%92%8a-114-explica-este-codigo-javascript/>
VANCOUVER
Cristian Fernando | Sciencx - » Paracetamol.js💊| #114: Explica este código JavaScript. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/05/11/paracetamol-js%f0%9f%92%8a-114-explica-este-codigo-javascript/
CHICAGO
" » Paracetamol.js💊| #114: Explica este código JavaScript." Cristian Fernando | Sciencx - Accessed . https://www.scien.cx/2022/05/11/paracetamol-js%f0%9f%92%8a-114-explica-este-codigo-javascript/
IEEE
" » Paracetamol.js💊| #114: Explica este código JavaScript." Cristian Fernando | Sciencx [Online]. Available: https://www.scien.cx/2022/05/11/paracetamol-js%f0%9f%92%8a-114-explica-este-codigo-javascript/. [Accessed: ]
rf:citation
» Paracetamol.js💊| #114: Explica este código JavaScript | Cristian Fernando | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.