Promise Returns

by mattoconnell408

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.23.0/polyfill.js"></script>

JavaScript

const p1 = new Promise(resolve => {
  setTimeout(
    () => resolve('p1 value'),
    3000
  );
  
});

const p2 = new Promise(resolve => {
  setTimeout(
    () => resolve('p2 value'),
    2000
  );
 });

function a() {
	return p1;
}

function b() {
	return p1.then(p2);
}

// b().then(val => alert(val));

a().then(val => alert(val)).then(val => alert(val))