JSFiddle - React, Tailwind, and code Playground

JavaScript

console.clear();

var x = 0;

var promise = new Promise(function(resolve, reject) {
  for (var i = 0; i < 10000001; i++) {
    x = i;
  }
  if (x === 10000000) {
    resolve(x);
  } else {
    reject("x != 10000000, x = " + x);
  }
});

promise.then(function(x) {
  console.log("Success! x = " + x);
});

promise.catch(function(reason) {
  console.error(reason);
});

console.log("loop");