Use export to Reuse a Code Block

Use export to Reuse a Code Block


bro, you are a champ!!!


That’s what worked for me as well. Thanks for sharing. A weird solution! :confused:


this PR is here you just change export const bar = “foo”;
bar = “foo”; not bar= “foo”; OMG i can’t image that ?


I’m still having the same problem

thanks guys for the solutions!


Brain wrecked over a typo or lack of space in pre-written code

Small stuff like this is enough to turn students away who may stress more

The solution is blurred so just click to see the issue

"use strict"; export const foo = "bar"; export const bar = "foo";


“use strict”;
const foo = “bar”;
const bar= “foo”;
if you guys can see there is a space present after the constant foo and before the “=” sign
but no space is present after the constant bar and before the “=” sign.
so the required solution is to add export inline and also add a space in const bar before “=” sign. :stuck_out_tongue:

the final solution would be:

“use strict”;
export const foo = “bar”;
export const bar = “foo”;


Did this challenge few days ago only to return yesterday and found it unsolved, and not just this, it happened to some of my other challenges too.

And I applied this solution, just like I did in the first, and as others have suggested but no luck. I even switch browser (from opera to Mozilla) , no luck. Not sure what the problem is.


I know the problem, Please note!
there is a space missing after the = sign.
const bar= “foo”; => const bar = “foo”;


Thank you but… I don’t think that should be an error ? what do you think?
We have to put a space between “bar” and “=”
“use strict”;
export const foo = “bar”;
export const bar = “foo”;


This is still not working for me. This is my code
“use strict”;
const foo= “bar”;
const bar= “foo”;

export const foo= “bar”
export const bar= “foo”

please tell me what I am doing wrong! it doesn’t pass the challenge at all.


instead of duplicating the const statements, just add export to the existing statements.
(right now you have two lines with const foo and two lines with const bar which is incorrect. Just reset the code and add the export next to each existing const definition)

Also please note there is a bug in the code, and to pass it you have to leave a blank space on the left and right of the equal sign.

hope this helps


yes it should not be an error . It is only an error because the FCC challenge has an open issue (bug). When they fix it, code with no space next to the = will work


I also have the similar problem.


Use this Solution for this Problem.

“use strict”;
export const foo = “bar”;
export const bar = “foo”;


It all comes down to whitespaces - space.


I love this site and appreciate the lessons. I do wish they would clarify the instructions though.

export const foo = "bar";
export const bar= "foo";

I could not complete the challenge because of no space after bar constant, rather than actual learning of topic I am dealing with something else.


just add export const to the provided code.


Solution is very simple and also provided in the example:

export { capitalizeString } //How to export functions.
export const foo = “bar”; //How to export variables.

Because of that, simply write:

“use strict”;
export const foo = “bar”;
export const bar = “foo”;

Hope this is helpful for anyone.