Kristofer Koishigawa b3213fc892 fix(i18n): chinese test suite (#38220)
* fix: Chinese test suite

Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working.

* fix: ran script, updated testStrings and solutions
2020-03-03 18:49:47 +05:30

1.6 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
587d7b8d367417b2b2512b59 Import a Default Export 1 导入默认导出

Description

在上一次挑战中,您了解了export default及其用途。请务必注意,要导入默认导出,您需要使用不同的import语法。在下面的示例中,我们有一个函数add ,它是文件的默认导出"math_functions" 。以下是如何导入它:
从“math_functions”导入添加;
添加5,4; //将返回9
语法在一个关键位置有所不同 - 导入的值add不会被花括号{}包围。与导出值不同,导入默认导出的主要方法是在import后简单地写入值的名称。

Instructions

在下面的代码中,请从文件"math_functions"导入默认导出, subtract ,该文件位于与此文件相同的目录中。

Tests

tests:
  - text: 正确导入<code>export default</code>方法。
    testString: assert(code.match(/import\s+subtract\s+from\s+('|")\.\/math_functions\.js\1/g));

Challenge Seed

"use strict";
subtract(7,4);

Before Test

window.require = function(str) {
if (str === 'math_functions') {
return function(a, b) {
return a - b;
}}};

Solution

// solution required