2.7 KiB
2.7 KiB
id, title, challengeType, forumTopicId, localeTitle
id | title | challengeType | forumTopicId | localeTitle |
---|---|---|---|---|
587d7b8c367417b2b2512b57 | Use * to Import Everything from a File | 1 | 301210 | Используйте *, чтобы импортировать все из файла |
Description
"math_functions"
импортируется в файл в том же каталоге: import * как myMathModule из "math_functions";И разбив этот код:
myMathModule.add (2,3);
myMathModule.subtract (5,3);
import * как object_with_name_of_your_choice из "file_path_goes_here"Вы можете использовать любое имя после
object_with_name_of_your_choice.imported_function
import * as
часть инструкции. Чтобы использовать этот метод, для него требуется объект, который получает импортированные значения. Здесь вы будете использовать точечную нотацию, чтобы вызвать ваши импортированные значения.
Instructions
"capitalize_strings"
, найденного в том же каталоге, который он импортировал. Добавьте соответствующий оператор import *
в начало файла, используя предоставленный объект.
Tests
tests:
- text: Properly uses <code>import * as</code> syntax.
testString: assert(code.match(/import\s*\*\s*as\s+stringFunctions\s+from\s*('|")\.\/string_functions\.js\1/g));
Challenge Seed
// add code above this line
stringFunctions.uppercaseString("hello");
stringFunctions.lowercaseString("WORLD!");
Solution
import * as stringFunctions from "./string_functions.js";
// add code above this line
stringFunctions.uppercaseString("hello");
stringFunctions.lowercaseString("WORLD!");