Use * to Import Everything from a File HELP

Use * to Import Everything from a File HELP
0

#1

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:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use--to-import-everything-from-a-file


#2

I’m stupid. Turns out myObj works!


#3

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?


#4

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


#5

Thank you so much! :smiley:


#6

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


#7

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


#8

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


#9

So silly, I made the same mistake¡¡


#10

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.


#11

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


#12

Question Answer

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

#13

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.


#14

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.


#15

Thank you @chuckadams for the clarification :slight_smile:


#16

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