* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.2 KiB
1.2 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d7b8d367417b2b2512b59 | Import a Default Export | 1 | 301205 | import-a-default-export |
--description--
In the last challenge, you learned about export default
and its uses. To import a default export, you need to use a different import
syntax. In the following example, add
is the default export of the math_functions.js
file. Here is how to import it:
import add from "./math_functions.js";
The syntax differs in one key place. The imported value, add
, is not surrounded by curly braces ({}
). add
here is simply a variable name for whatever the default export of the math_functions.js
file is. You can use any name here when importing a default.
--instructions--
In the following code, import the default export from the math_functions.js
file, found in the same directory as this file. Give the import the name subtract
.
--hints--
You should properly import subtract
from math_functions.js
.
assert(code.match(/import\s+subtract\s+from\s+('|")\.\/math_functions\.js\1/g));
--seed--
--seed-contents--
// Only change code above this line
subtract(7,4);
--solutions--
import subtract from "./math_functions.js";
subtract(7,4);