Rick's Question About Promise Structure

I can't figure out why the function "cat" doesn't resolve its promise as soon as the first timeout expires.

by Rick Hedin

HTML

<title>Rick's Question About Promise Structure</title>

JavaScript

function promiseAfter(seconds) {
  var promise = new Promise( (resolve) => {
    setTimeout(function () {resolve()}, 1000 * seconds)
  })
  return promise;
}

function dog() {
  console.log('Dog has started')
  cat().then(function () {
    console.log('In Dog. Cat has finished')
  })
  console.log('Dog has finished')
}

function cat() {
  console.log('Cat has started')
  return promiseAfter(1).then( () => {
    console.log('In Cat.  Outer promise satisfied')
    return promiseAfter(1).then( () => {
      console.log('In Cat.  Inner promise satisfied')
    })
  })
  console.log('Anything after the return stmt in Cat is never executed')
}

dog();