JSFiddle - React, Tailwind, and code Playground

by Matthew Day

JavaScript

var passInteger = function(int) {
	let promise = new Promise((res, rej) => {
  	setTimeout(function() {
    	if(int === NaN) {
      	console.error("Not a number");
      	return false;
      } else {
      	res(int);
      }
    }, 1000);
  });
  return promise;
}

var addInteger = function(int) {
	let promise = new Promise((res, rej) => {
  	setTimeout(function() {
    	if(int === NaN) {
      	console.error("Not a number");
      	return false;
      } else {
      	res(int + 10);
      }
    }, 2000);
  });
  return promise;
}

var printResult = function(res) {
	console.log(res);
}



passInteger(4)
	.then(addInteger)
  .then(printResult);