Feat: add new Markdown parser (#39800)
and change all the challenges to new `md` format.
This commit is contained in:
committed by
GitHub
parent
a07f84c8ec
commit
0bd52f8bd1
@ -1,53 +1,65 @@
|
||||
---
|
||||
title: FizzBuzz
|
||||
id: 5e9ddb06ec35240f39657419
|
||||
title: FizzBuzz
|
||||
challengeType: 5
|
||||
forumTopicId: 385370
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
# --description--
|
||||
|
||||
Write a program that generates an array of integers from 1 to 100 (inclusive). But:
|
||||
|
||||
<ul>
|
||||
<li>for multiples of 3, add <code>"Fizz"</code> to the array instead of the number</li>
|
||||
<li>for multiples of 5, add <code>"Buzz"</code> to the array instead of the number</li>
|
||||
<li>for multiples of 3 and 5, add <code>"FizzBuzz"</code> to the array instead of the number</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
# --instructions--
|
||||
|
||||
Your program should return an array containing the results based on the rules above.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
# --hints--
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>fizzBuzz</code> should be a function.
|
||||
testString: assert(typeof fizzBuzz=='function');
|
||||
- text: <code>fizzBuzz()</code> should return an Array.
|
||||
testString: assert(Array.isArray(fizzBuzz())==true);
|
||||
- text: Numbers divisible by only 3 should return <code>"Fizz"</code>.
|
||||
testString: assert.equal(fizzBuzz()[2], "Fizz");
|
||||
- text: Numbers divisible by only 5 should return <code>"Buzz"</code>.
|
||||
testString: assert.equal(fizzBuzz()[99], "Buzz");
|
||||
- text: Numbers divisible by both 3 and 5 should return <code>"FizzBuzz"</code>.
|
||||
testString: assert.equal(fizzBuzz()[89], "FizzBuzz");
|
||||
- text: Numbers not divisible by either 3 or 5 should return the number itself.
|
||||
testString: assert.equal(fizzBuzz()[12], 13);
|
||||
`fizzBuzz` should be a function.
|
||||
|
||||
```js
|
||||
assert(typeof fizzBuzz == 'function');
|
||||
```
|
||||
|
||||
</section>
|
||||
`fizzBuzz()` should return an Array.
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
```js
|
||||
assert(Array.isArray(fizzBuzz()) == true);
|
||||
```
|
||||
|
||||
<div id='js-seed'>
|
||||
Numbers divisible by only 3 should return `"Fizz"`.
|
||||
|
||||
```js
|
||||
assert.equal(fizzBuzz()[2], 'Fizz');
|
||||
```
|
||||
|
||||
Numbers divisible by only 5 should return `"Buzz"`.
|
||||
|
||||
```js
|
||||
assert.equal(fizzBuzz()[99], 'Buzz');
|
||||
```
|
||||
|
||||
Numbers divisible by both 3 and 5 should return `"FizzBuzz"`.
|
||||
|
||||
```js
|
||||
assert.equal(fizzBuzz()[89], 'FizzBuzz');
|
||||
```
|
||||
|
||||
Numbers not divisible by either 3 or 5 should return the number itself.
|
||||
|
||||
```js
|
||||
assert.equal(fizzBuzz()[12], 13);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function fizzBuzz() {
|
||||
@ -55,12 +67,7 @@ function fizzBuzz() {
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
function fizzBuzz() {
|
||||
@ -82,5 +89,3 @@ function fizzBuzz() {
|
||||
return res;
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
|
Reference in New Issue
Block a user