question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ES6: Use * to import Everything from a File

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
abhijeetpscommented, Jun 22, 2018

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.

4reactions
nathanhannigcommented, Aug 29, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to import everything exported from a file with ES2015 ...
In ES6, with below code, imported content can be used without wrap object. Just put it here for someone like me who ends...
Read more >
Use * to Import Everything from a File - FreeCodeCamp - GitHub
The code in this file requires the contents of the file: string_functions.js , that is in the same directory as the current file....
Read more >
import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live bindings which are exported by another module. The imported bindings are ...
Read more >
Import all Exports from a File in JavaScript | bobbyhadz
Export all members you intend to import from file A . · Import all the exports in file B as import * as...
Read more >
ES6 Modules and How to Use Import and Export in JavaScript
You can export members one by one. What's not exported won't be available directly outside the module: export const myNumbers = [1 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found