1.6 KiB
1.6 KiB
id | challengeType | forumTopicId | localeTitle |
---|---|---|---|
587d7b84367417b2b2512b36 | 1 | 301190 | 捕获未闭合的括号、方括号、大括号和引号 |
Description
Instructions
Tests
tests:
- text: 你应该修复数组缺少的部分。
testString: assert(code.match(/myArray\s*?=\s*?\[\s*?1\s*?,\s*?2\s*?,\s*?3\s*?\];/g));
- text: '你应该修复<code>.reduce()</code>方法缺少的部分。控制台应输出 "Sum of array values is: 6"。'
testString: 'assert(arraySum === 6);'
Challenge Seed
let myArray = [1, 2, 3;
let arraySum = myArray.reduce((previous, current => previous + current);
console.log(`Sum of array values is: ${arraySum}`);
Solution
let myArray = [1, 2, 3];
let arraySum = myArray.reduce((previous, current) => previous + current);
console.log(`Sum of array values is: ${arraySum}`);