promise-it-wont-hurt icon indicating copy to clipboard operation
promise-it-wont-hurt copied to clipboard

lesson #2

Open isomorphisms opened this issue 8 years ago • 2 comments

I don't understand how to get a promise to be fulfilled by the end of lesson 2. Here is what I run

const yes = () => return 'YES'
const no = () => return 'NO'
const wtf = () => return 'This should never happen!'

var p = new Promise( function(y,n) {
  if(y) return yes
  else if(n) return no
  else return wtf
  }
  )

This runs in the node repl: I actually create a promise. But then how do I make it succeed? Do I pass something? (No: node repl tells me p is not a function.) And what does then mean? This is what I came here to find out.

Also your front page says this is updated weekly, but talking about ES6 polyfill seems like something I don't need to do with the latest node?

isomorphisms avatar Oct 30 '17 04:10 isomorphisms

ok, this answered my question: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise

so the proper structure for a promise is

var p = new Promise( (a,b) => a("working") )

isomorphisms avatar Oct 30 '17 05:10 isomorphisms

I guess looking back you did say this somewhere in lesson #2. But I didn't understand it from what you said. (probably too much text)

isomorphisms avatar Oct 30 '17 05:10 isomorphisms