promise-it-wont-hurt
promise-it-wont-hurt copied to clipboard
lesson #2
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?
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") )
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)