Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lesson #2 #135

Open
isomorphisms opened this issue Oct 30, 2017 · 2 comments
Open

lesson #2 #135

isomorphisms opened this issue Oct 30, 2017 · 2 comments

Comments

@isomorphisms
Copy link

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
Copy link
Author

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
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant