chore(learn): Applied MDX format to Chinese curriculum files (#40462)

This commit is contained in:
Randell Dawson
2020-12-16 00:37:30 -07:00
committed by GitHub
parent 873fce02a2
commit 9ce4a02a41
1665 changed files with 58741 additions and 88042 deletions

View File

@ -1,95 +1,88 @@
---
id: 595011cba5a81735713873bd
title: 每组排名最高
challengeType: 5
videoUrl: ''
title: 每组排名最高
---
## Description
<section id="description">任务: <p>在每个组中查找排名前N位的数据其中N作为参数提供。等级和组的名称也作为参数提供。 </p>鉴于以下数据: <pre> [
{姓名:&#39;Tyler Bennett&#39;id&#39;E10297&#39;薪水32000部门&#39;D101&#39;}
{姓名:&#39;John Rappl&#39;id&#39;E21437&#39;薪水47000部门&#39;D050&#39;}
{姓名:&#39;George Woltman&#39;id&#39;E00127&#39;薪水53500部门&#39;D101&#39;}
{name&#39;Adam Smith&#39;id&#39;E63535&#39;薪水18000部门&#39;D202&#39;}
{姓名:&#39;Claire Buckman&#39;id&#39;E39876&#39;薪水27800部门&#39;D202&#39;}
{姓名:&#39;David McClellan&#39;id&#39;E04242&#39;薪水41500部门&#39;D101&#39;}
{name&#39;Rich Holcomb&#39;id&#39;E01234&#39;薪水49500dept&#39;D202&#39;}
{姓名:&#39;Nathan Adams&#39;id&#39;E41298&#39;薪水21900部门&#39;D050&#39;}
{姓名:&#39;Richard Potter&#39;id&#39;E43128&#39;,薪水:15900部门&#39;D101&#39;}
{姓名:&#39;David Motsinger&#39;id&#39;E27002&#39;薪水19250dept&#39;D202&#39;}
{姓名:&#39;Tim Sampair&#39;id&#39;E03033&#39;,薪水:27000部门&#39;D101&#39;}
{姓名:&#39;Kim Arlich&#39;id&#39;E10001&#39;,薪水:57000部门&#39;D190&#39;}
{name&#39;Timothy Grove&#39;id&#39;E16398&#39;薪水29900部门&#39;D190&#39;}
# --description--
任务:
在每个组中查找排名前N位的数据其中N作为参数提供。等级和组的名称也作为参数提供。
鉴于以下数据:
```
[
{姓名:'Tyler Bennett'id'E10297',薪水:32000部门'D101'}
{姓名:'John Rappl'id'E21437'薪水47000部门'D050'}
{姓名:'George Woltman'id'E00127',薪水:53500部门'D101'}
{name'Adam Smith'id'E63535',薪水:18000部门'D202'}
{姓名:'Claire Buckman'id'E39876'薪水27800部门'D202'}
{姓名:'David McClellan'id'E04242'薪水41500部门'D101'}
{name'Rich Holcomb'id'E01234'薪水49500dept'D202'}
{姓名:'Nathan Adams'id'E41298'薪水21900部门'D050'}
{姓名:'Richard Potter'id'E43128'薪水15900部门'D101'}
{姓名:'David Motsinger'id'E27002'薪水19250dept'D202'}
{姓名:'Tim Sampair'id'E03033'薪水27000部门'D101'}
{姓名:'Kim Arlich'id'E10001'薪水57000部门'D190'}
{name'Timothy Grove'id'E16398'薪水29900部门'D190'}
]。
</pre>通过调用<code>topRankPerGroup(10, data, &#39;dept&#39;, &#39;salary&#39;)</code>可以对每个部门的前10名员工进行排名。给出以下数据 <pre> [
{name&#39;Friday 13th&#39;,类型:&#39;恐怖&#39;评分9.9}
{姓名:“榆树街上的梦魇”,类型:&#39;恐怖&#39;等级5.7}
{name&#39;Titanic&#39;,类型:&#39;drama&#39;,评分:7.3}
{name&#39;Maze Runner&#39;,类型:&#39;scifi&#39;评级7.1}
{name&#39;Blade runner&#39;,类型:&#39;scifi&#39;评分8.9}
```
</pre>通过调用<code>topRankPerGroup(10, data, 'dept', 'salary')</code>可以对每个部门的前10名员工进行排名。给出以下数据 <pre> [
{name'Friday 13th',类型:'恐怖',评分:9.9}
{姓名:“榆树街上的梦魇”,类型:'恐怖'等级5.7}
{name'Titanic',类型:'drama'评分7.3}
{name'Maze Runner',类型:'scifi'评级7.1}
{name'Blade runner',类型:'scifi'评分8.9}
]。
</pre>通过调用<code>topRankPerGroup(1, data, &#39;genre&#39;, &#39;rating&#39;)</code>可以在每个类型中对排名最高的电影进行排名</section>
</pre>通过调用<code>topRankPerGroup(1, data, 'genre', 'rating')</code>可以在每个类型中对排名最高的电影进行排名
## Instructions
<section id="instructions">
</section>
# --hints--
## Tests
<section id='tests'>
```yml
tests:
- text: <code>topRankPerGroup</code>是一个函数。
testString: assert(typeof topRankPerGroup === 'function');
- text: <code>topRankPerGroup</code>在负n值上返回undefined。
testString: assert(typeof topRankPerGroup(-1, []) === 'undefined');
- text: 第一部门必须是D050
testString: assert.equal(res1[0][0].dept, 'D050');
- text: 第一部门必须是D050
testString: assert.equal(res1[0][1].salary, 21900);
- text: 最后一个部门必须是D202
testString: assert.equal(res1[3][3].dept, 'D202');
- text: '<code>topRankPerGroup(1, ...)</code>必须仅返回每组的排名最高的结果。'
testString: assert.equal(res2[2].length, 1);
- text: '<code>topRankPerGroup(1, ...)</code>必须仅返回每组的排名最高的结果。'
testString: assert.equal(res3[2][1].name, 'Maze Runner');
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
`topRankPerGroup`是一个函数。
```js
function topRankPerGroup(n, data, groupName, rankName) {
// Good luck!
return true;
}
assert(typeof topRankPerGroup === 'function');
```
</div>
### After Test
<div id='js-teardown'>
`topRankPerGroup`在负n值上返回undefined。
```js
console.info('after the test');
assert(typeof topRankPerGroup(-1, []) === 'undefined');
```
</div>
</section>
## Solution
<section id='solution'>
第一部门必须是D050
```js
// solution required
assert.equal(res1[0][0].dept, 'D050');
```
/section>
第一部门必须是D050
```js
assert.equal(res1[0][1].salary, 21900);
```
最后一个部门必须是D202
```js
assert.equal(res1[3][3].dept, 'D202');
```
`topRankPerGroup(1, ...)`必须仅返回每组的排名最高的结果。
```js
assert.equal(res2[2].length, 1);
```
`topRankPerGroup(1, ...)`必须仅返回每组的排名最高的结果。
```js
assert.equal(res3[2][1].name, 'Maze Runner');
```
# --solutions--