JSFiddle - React, Tailwind, and code Playground

by velmurugansp

JavaScript

/* function printSomething(){
  console.log("JavaScript is interesting");
}

var interval = setTimeout(printSomething, 8000);

if(prompt("Shall I print?")  == "No"){
  clearInterval(interval);
} */

function wonOrLost(resolve, reject){
	
  setTimeout(function(){
    let c = Math.floor(Math.random()*10);		
    console.log(c);
    if(c >= 5){
      resolve("Success");
    }
    else{
      reject("Failed");
    }  
  }, 5000);
  console.log("India");
}
let goodPromise = new Promise(wonOrLost);
goodPromise.then(won).catch(lost);
function won(info){
	console.log("WOW" + info);
}
function lost(data){
	console.log("OMG" + data);
}