Freecodecamp: ES6: Use * to import Everything from a File

Created on 20 Jun 2018  路  12Comments  路  Source: freeCodeCamp/freeCodeCamp

Describe your problem and - if possible - how to reproduce it

there is still a problem with this exercise.
the challenge states:

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.

which is fine, but it doesn't give complete information to complete the challenge, I had to look in

ES6: Use * to Import Everything from a File - import name ambiguity #16356
to see what is ACTUALLY expected.

the code section has one line only:
"use strict";

there is absolutely nothing in the body of the explanation or the challenge description telling us what is actually required in the code!

if you do what it asks by adding:

import * as myModule from "capitalize_strings";

it gives an error when you run the code that is less than helpful:

uses import * as properly

nowhere in the description does it say to use the module or what is in the module

for example:

"use strict";
import * as myModule from "capitalize_strings";
myModule.capitalize("foo");
myModule.lowercase("Bar");

interestingly however, now that I've had a successful test it passes with only the import line added to the code. I tried to repeat the error in firefox, originally the test was done in chrome, but again it passes the test with only the import * as myModule from "capitalize_strings"; line

This test would not pass previously until the code above created a successful result.

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

  • Browser Name: Chrome
  • Browser Version: Version 67.0.3396.87 (Official Build) (64-bit)
  • Operating System: Windows 10
learn

Most helpful comment

Okay, for those facing problems with https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use--to-import-everything-from-a-file/
Remember two important things:
The syntax is:

import * as object_with_name_of_your_choice from "file_path_goes_here";

In the above, the Double Quotes (" ") and the Line ending semi-colon (;) is very important. Also, make sure that the file path is correct. It doesn't matter what name your object is having.

I am not sure why this is happening and it shouldn't happen.

I think I can work on this and open a PR if someone guides me where I have to edit the checks.

All 12 comments

This may have been just a glitch. I followed along as someone else did this challenge today and the issue was not reproducible.

Okay, for those facing problems with https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use--to-import-everything-from-a-file/
Remember two important things:
The syntax is:

import * as object_with_name_of_your_choice from "file_path_goes_here";

In the above, the Double Quotes (" ") and the Line ending semi-colon (;) is very important. Also, make sure that the file path is correct. It doesn't matter what name your object is having.

I am not sure why this is happening and it shouldn't happen.

I think I can work on this and open a PR if someone guides me where I have to edit the checks.

Oh, and I feel there's another bug. 馃悰
And this bug is not only with this problem, but with a few other previous problems.

To access file from the same location, we can use "file_path_goes_here" or "./file_path_goes_here". The second case doesn't work in the problem and some previous problems. I personally prefer the second while actually producing an app.

Please let me know where can I make changes and open a PR for the same. 馃槃

The code below requires the contents of a file, "capitalize_strings", found in the same directory as it, imported. Add the appropriateimport *statement to the top of the file, _using the _object provided__.

The last statement saying _using the object provided_ is a bit confusing as none is.

Here is what needs to change

Remove , using the object provided
Allow single quotes around filename
Allow no end semicolon

Updates to this challenge should also occur for
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/understand-the-differences-between-import-and-require
and
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/import-a-default-export

any idea why the following code below is not accepted?

task;
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.

my solution; (not accepted)

import { capitalizeString } from "capitalize_strings";
capitalizeString("hello!");

suggestions and help greatly appreciated! thx.

@ZokiMar I think you are confusing two different challenges.

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

import * as myModule from "capitalize_strings";
myModule.capitalize("hello!");

and for https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/understand-the-differences-between-import-and-require

import { capitalizeString } from 'string_functions'
capitalizeString("hello!");

Wanted to elaborate that the challenge does not pass when single quotes are used around the file name.

+1 @nathanhannig : Allow single quotes around filename

This one was so frustrating... and I also agree that they need to either remove the statement "...using the object provided." or update the code to reflect that statement.

The following did NOT pass:
import * as capStrings from "capitalize_strings"
"use strict";

However, this did pass:
import * as capStrings from "capitalize_strings";
"use strict";

Hi there, I've been currently doing this exercise but I did encounter the single; double quotes issues which looks to be mentioned here and I don't know if it should still supposed to be the case today ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SaintPeter picture SaintPeter  路  3Comments

robwelan picture robwelan  路  3Comments

raisedadead picture raisedadead  路  3Comments

MichaelLeeHobbs picture MichaelLeeHobbs  路  3Comments

imhuyqn picture imhuyqn  路  3Comments