* 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
1.6 KiB
1.6 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7b8c367417b2b2512b58 | Create an Export Fallback with export default | 1 | 使用导出默认值创建导出回退 |
Description
export
课程中,您了解了称为命名导出的语法。这使您可以使多个函数和变量可用于其他文件。您需要知道另一种export
语法,称为导出默认值 。通常,如果只从文件导出一个值,您将使用此语法。它还用于为文件或模块创建回退值。以下是export default
的快速示例: export default function add(x,y){注意:由于
return x + y;
}
export default
用于声明模块或文件的回退值,因此每个模块或文件中只能有一个值作为默认导出。此外,您不能将export default
用于var
, let
或const
Instructions
Tests
tests:
- text: 适当使用<code>export</code>回落。
testString: assert(code.match(/export\s+default\s+function(\s+subtract\s*|\s*)\(\s*x,\s*y\s*\)\s*{/g));
Challenge Seed
"use strict";
function subtract(x,y) {return x - y;}
Before Test
window.exports = function(){};
Solution
// solution required