Use export to Reuse a Code Block

Use export to Reuse a Code Block
0

#22

bro, you are a champ!!!


#23

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


#24

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


#25

I’m still having the same problem

thanks guys for the solutions!


#26

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";


#27

“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”;


#28

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.


#29

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


#30

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”;


#31

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.


#32

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


#33

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


#34

I also have the similar problem.


#35

Use this Solution for this Problem.

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


#36

It all comes down to whitespaces - space.


#37

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


#38
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.


#39

just add export const to the provided code.


#40

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.