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

Exercise 8 #110

Open
JavierMendozaGomez opened this issue Jan 2, 2017 · 2 comments
Open

Exercise 8 #110

JavierMendozaGomez opened this issue Jan 2, 2017 · 2 comments

Comments

@JavierMendozaGomez
Copy link

HI i got this problem with the execution of exercise 8:

The Task

Construct a promise chain that returns values to prove to yourself that
promise handlers will wrap your returned values in promises allowing
additional chaining.

  • Declare a function attachTitle which prepends 'DR. ' to its firstargument and returns the result.
  • Create a fulfilled promise with a value of 'MANHATTAN'.
  • Build a promise chain off the promise we just constructed that first callsattachTitle then calls console.log.

If your program runs successfully, it should print out “DR. MANHATTAN” which
is extremely exciting.

My code:

3

The response
2

thanks for reading me

@robbiedhickey
Copy link

This is failing because the workshopper enforces an assumption that the name of the function passed to your first then() call will be 'attachTitle' (it uses the name property of the function to determine this). In your case, you are using an anonymous function expression and assigning to a variable named attachTitle, so the 'name' property will be empty. You should be able to fix this with a function declaration or named function expression:

// function declaration
function attachTitle(word) {
  return 'DR. ' + word;
}

// named function expression
var attachTitle = function attachTitle(word) {
  return 'DR. ' + word;
}

There is another scenario in this issue that reports a false negative for a similar reason: nodeschool/discussions#2002

CC @TimothyGu - any thoughts on how to mitigate these false negatives? Looking at the code it is not obvious to me how we could handle these scenarios without removing the check.

@senpl
Copy link

senpl commented Sep 24, 2018

I do not understand why this is incorrect
.then(val => attachTitle(val)).then(console.log);
but this is correct
.then(attachTitle).then(console.log);
They seems that same one is just shorter.

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

3 participants