1.9 KiB
1.9 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d824d367417b2b2512c50 | 測試某個值是否爲數組 | 2 | 301600 | test-if-a-value-is-an-array |
--description--
請注意,本項目在這個 Replit 項目的基礎上進行開發。你也可以從 GitHub 上克隆。
--instructions--
在 tests/1_unit-tests.js
中,Arrays
套件裏標有 #11
的測試下,將每個 assert
改成 assert.isArray
或 assert.isNotArray
方法,通過測試(結果應該返回 true
)。 不要改變傳入斷言的參數。
--hints--
不應有未通過的測試
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=10').then(
(data) => {
assert.equal(data.state, 'passed');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
請選擇正確的斷言——isArray
或 isNotArray
。
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=10').then(
(data) => {
assert.equal(
data.assertions[0].method,
'isArray',
'String.prototype.split() returns an Array'
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
請選擇正確的斷言——isArray
或 isNotArray
。
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=10').then(
(data) => {
assert.equal(
data.assertions[1].method,
'isNotArray',
'Array.prototype.indexOf() returns a number'
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
--solutions--
/**
Backend challenges don't need solutions,
because they would need to be tested against a full working project.
Please check our contributing guidelines to learn more.
*/