3.2 KiB
3.2 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d8250367417b2b2512c60 | Create a Queue Class | 1 | 创建队列类 |
Description
Instructions
Tests
tests:
- text: 您的<code>Queue</code>类应该有一个<code>enqueue</code>方法。
testString: assert((function(){var test = new Queue(); return (typeof test.enqueue === 'function')}()));
- text: 您的<code>Queue</code>类应该有一个<code>dequeue</code>方法。
testString: assert((function(){var test = new Queue(); return (typeof test.dequeue === 'function')}()));
- text: 您的<code>Queue</code>类应该有一个<code>front</code>方法。
testString: assert((function(){var test = new Queue(); return (typeof test.front === 'function')}()));
- text: 您的<code>Queue</code>类应该有一个<code>size</code>方法。
testString: assert((function(){var test = new Queue(); return (typeof test.size === 'function')}()));
- text: 您的<code>Queue</code>类应该有一个<code>isEmpty</code>方法。
testString: assert((function(){var test = new Queue(); return (typeof test.isEmpty === 'function')}()));
- text: <code>dequeue</code>方法应该删除并返回队列的前端元素
testString: assert((function(){var test = new Queue(); test.enqueue('Smith'); test.enqueue('John'); return (test.dequeue() === 'Smith')}()));
- text: <code>front</code>方法应该返回队列的front元素的值
testString: assert((function(){var test = new Queue(); test.enqueue('Smith'); test.enqueue('John'); return (test.front() === 'Smith')}()));
- text: <code>size</code>方法应该返回队列的长度
testString: assert((function(){var test = new Queue(); test.enqueue('Smith'); return (test.size() === 1)}()));
- text: 如果队列中有元素,则<code>isEmpty</code>方法应返回<code>false</code>
testString: assert((function(){var test = new Queue(); test.enqueue('Smith'); return !(test.isEmpty())}()));
Challenge Seed
function Queue () {
var collection = [];
this.print = function() {
console.log(collection);
};
// Only change code below this line
// Only change code above this line
}
Solution
// solution required
/section>