Use * to Import Everything from a File HELP

Tell us what’s happening:

Instructions:

The code below requires the contents of a file, “capitalize_strings”, found in the same directory as it, imported. Add the appropriate import * statement to the top of the file, using the object provided.

What object provided? I get that import * as myObj from "capitalize_strings" syntax but I can’t figure out the “object provided”.

Your code so far


"use strict";
import * as myObj from "capitalize_strings"

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:

I’m stupid. Turns out myObj works!

No, you are not stupid, the question is not well written.

I still can’t pass the test of this silly question, what is the trick?

6 Likes

OK, I got if finally. the semicolon at the end of the import is mandatory! /_-

12 Likes

Thank you so much! :smiley:

ES6 is full of bugs.

1st,
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/declare-a-read-only-variable-with-the-const-keyword

Then,
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-getters-and-setters-to-control-access-to-an-object

again,
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-export-to-reuse-a-code-block

and Now,
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use--to-import-everything-from-a-file

4 Likes

simply the error i gone by adding " ; " after import

This question definitely needs re-writing. Using “myObj” worked for me finally. Thanks!

1 Like

So silly, I made the same mistake¡¡

Simply write:

“use strict”;
import * as whatever from “capitalize_strings”;

The most important thing is not to forget the ; - semicolon at the end of the import statement.

Replacing the single quotes by double quotes did the trick for me.

3 Likes

Question Answer

Reveal
"use strict";
import * as capitalize_strings from "capitalize_strings"; 

Does anyone know why we have to write the answer as

"use strict";
import * as myObj from "capitalize_strings";

and not:

import * as myObj from "capitalize_strings";
"use strict";

Thanks in advance.

The acceptance tests for this challenge are just overly specific, which caused the problems the OP had. However, "use strict"; does have to be the very first thing before any other statements in a file or a function, so that particular test isn’t wrong.

Thank you @chuckadams for the clarification :slight_smile:

the answer requires you to use " instead of ' someone should update the tests for this

was trying to figure out why it wouldn’t work but this worked for me.

use " instead of ’ and make sure to add a ; add the end of the import. that solved it for me :slight_smile: