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: failing due to fulfillment with function call? #119

Closed
awitherow opened this issue Apr 5, 2017 · 2 comments
Closed

Exercise 8: failing due to fulfillment with function call? #119

awitherow opened this issue Apr 5, 2017 · 2 comments

Comments

@awitherow
Copy link

awitherow commented Apr 5, 2017

I have seen that the correct solution is returning a value, then passing that value to the attachTitle function, then console logging.

I did this approach and am failing for the reason shown also below.

require('es6-promise');

('use strict');

function attachTitle(arg) {
    return 'DR. ' + arg;
}

var manhattan = Promise.resolve(attachTitle('MANHATTAN')).then(console.log);
Your submission results compared to the expected:

                 ACTUAL                                 EXPECTED
────────────────────────────────────────────────────────────────────────────────

   "DR. MANHATTAN"                     ==    "DR. MANHATTAN"
   ""                                  ==    ""

────────────────────────────────────────────────────────────────────────────────

✓ Submission results match expected
✗ You didn’t create or didn’t use attachTitle method

# FAIL

Your solution to Values and promises didn't pass. Try again!

This IS returning a value at the end of the day, which is the point of the lesson?

@awitherow awitherow changed the title Exercise 8: failing with use of Promise.resolve? Exercise 8: failing due to resolution with function call? Apr 5, 2017
@awitherow awitherow changed the title Exercise 8: failing due to resolution with function call? Exercise 8: failing due to fulfillment with function call? Apr 5, 2017
@devserkan
Copy link

devserkan commented May 31, 2017

The point is here I think, workshop wants to show us although our function does not return a promise, onFulfill handler wraps it in a promise. So, this is why workshop expects us to use a function which does not return a promise and chain it with .then like it turns one! You are using your function (even invoke it) in resolve, so this is very usual. You are resolving a value there (from your function). Thus, you only chain two pieces: A promise and another function.

To sum up, workshop wants to emphasize if I don't understand wrong is that:

Promise -> .then -> function not returning promise -> but again .then -> another function

@awitherow
Copy link
Author

Alright thanks for the clarification!

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

2 participants