fix(curriculum): fix challenges for russian language

This commit is contained in:
Valeriy S
2019-08-28 16:26:13 +03:00
committed by mrugesh
parent a17c3c44aa
commit 12f65a6742
1418 changed files with 39634 additions and 19395 deletions

View File

@@ -2,15 +2,18 @@
title: Hash from two arrays
id: 595671d4d2cdc305f0d5b36f
challengeType: 5
videoUrl: ''
forumTopicId: 302283
localeTitle: Хэш из двух массивов
---
## Description
<section id="description"> Задача: <p> Используя два массива равной длины, создайте объект Hash, в котором элементы из одного массива (ключи) связаны с элементами другого (значения) </p> Связанная задача: <a href="http://rosettacode.org/wiki/Associative arrays/Creation" title="Ассоциативные массивы / Создание">Ассоциативные массивы / Создание</a> </section>
<section id='description'>
Задача: <p> Используя два массива равной длины, создайте объект Hash, в котором элементы из одного массива (ключи) связаны с элементами другого (значения) </p> Связанная задача: <a href="http://rosettacode.org/wiki/Associative arrays/Creation" title="Ассоциативные массивы / Создание">Ассоциативные массивы / Создание</a>
</section>
## Instructions
<section id="instructions">
<section id='instructions'>
</section>
## Tests
@@ -18,20 +21,20 @@ localeTitle: Хэш из двух массивов
```yml
tests:
- text: <code>arrToObj</code> - функция.
testString: 'assert(typeof arrToObj === "function", "<code>arrToObj</code> is a function.");'
- text: '<code>arrToObj([1, 2, 3, 4, 5], [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;])</code> должны возвращать <code>{ 1: &quot;a&quot;, 2: &quot;b&quot;, 3: &quot;c&quot;, 4: &quot;d&quot;, 5: &quot;e&quot; }</code>'
testString: 'assert.deepEqual(arrToObj(...testCases[0]), res[0], "<code>arrToObj([1, 2, 3, 4, 5], ["a", "b", "c", "d", "e"])</code> should return <code>{ 1: "a", 2: "b", 3: "c", 4: "d", 5: "e" }</code>");'
- text: '<code>arrToObj([1, 2, 3, 4, 5], [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;])</code> должны возвращать <code>{ 1: &quot;a&quot;, 2: &quot;b&quot;, 3: &quot;c&quot;, 4: &quot;d&quot;, 5: undefined }</code>'
testString: 'assert.deepEqual(arrToObj(...testCases[1]), res[1], "<code>arrToObj([1, 2, 3, 4, 5], ["a", "b", "c", "d"])</code> should return <code>{ 1: "a", 2: "b", 3: "c", 4: "d", 5: undefined }</code>");'
- text: '<code>arrToObj([1, 2, 3], [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;])</code> должны возвращать <code>{ 1: &quot;a&quot;, 2: &quot;b&quot;, 3: &quot;c&quot; }</code>'
testString: 'assert.deepEqual(arrToObj(...testCases[2]), res[2], "<code>arrToObj([1, 2, 3], ["a", "b", "c", "d", "e"])</code> should return <code>{ 1: "a", 2: "b", 3: "c" }</code>");'
- text: '<code>arrToObj([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;], [1, 2, 3, 4, 5])</code> должны возвращать <code>{ &quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: 3 , &quot;d&quot;: 4, &quot;e&quot;: 5 }</code>'
testString: 'assert.deepEqual(arrToObj(...testCases[3]), res[3], "<code>arrToObj(["a", "b", "c", "d", "e"], [1, 2, 3, 4, 5])</code> should return <code>{ "a": 1, "b": 2, "c": 3 , "d": 4, "e": 5 }</code>");'
- text: '<code>arrToObj([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;], [1, 2, 3, 4])</code> должны возвращать <code>{ &quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: 3 , &quot;d&quot;: 4, &quot;e&quot;: undefined }</code>'
testString: 'assert.deepEqual(arrToObj(...testCases[4]), res[4], "<code>arrToObj(["a", "b", "c", "d", "e"], [1, 2, 3, 4])</code> should return <code>{ "a": 1, "b": 2, "c": 3 , "d": 4, "e": undefined }</code>");'
- text: '<code>arrToObj([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;], [1, 2, 3, 4, 5])</code> должны возвращать <code>{ &quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: 3 }</code>'
testString: 'assert.deepEqual(arrToObj(...testCases[5]), res[5], "<code>arrToObj(["a", "b", "c"], [1, 2, 3, 4, 5])</code> should return <code>{ "a": 1, "b": 2, "c": 3 }</code>");'
- text: <code>arrToObj</code> is a function.
testString: assert(typeof arrToObj === 'function');
- text: '<code>arrToObj([1, 2, 3, 4, 5], ["a", "b", "c", "d", "e"])</code> should return <code>{ 1: "a", 2: "b", 3: "c", 4: "d", 5: "e" }</code>'
testString: assert.deepEqual(arrToObj(...testCases[0]), res[0]);
- text: '<code>arrToObj([1, 2, 3, 4, 5], ["a", "b", "c", "d"])</code> should return <code>{ 1: "a", 2: "b", 3: "c", 4: "d", 5: undefined }</code>'
testString: assert.deepEqual(arrToObj(...testCases[1]), res[1]);
- text: '<code>arrToObj([1, 2, 3], ["a", "b", "c", "d", "e"])</code> should return <code>{ 1: "a", 2: "b", 3: "c" }</code>'
testString: assert.deepEqual(arrToObj(...testCases[2]), res[2]);
- text: '<code>arrToObj(["a", "b", "c", "d", "e"], [1, 2, 3, 4, 5])</code> should return <code>{ "a": 1, "b": 2, "c": 3 , "d": 4, "e": 5 }</code>'
testString: assert.deepEqual(arrToObj(...testCases[3]), res[3]);
- text: '<code>arrToObj(["a", "b", "c", "d", "e"], [1, 2, 3, 4])</code> should return <code>{ "a": 1, "b": 2, "c": 3 , "d": 4, "e": undefined }</code>'
testString: assert.deepEqual(arrToObj(...testCases[4]), res[4]);
- text: '<code>arrToObj(["a", "b", "c"], [1, 2, 3, 4, 5])</code> should return <code>{ "a": 1, "b": 2, "c": 3 }</code>'
testString: assert.deepEqual(arrToObj(...testCases[5]), res[5]);
```
@@ -52,12 +55,28 @@ function arrToObj (keys, vals) {
</div>
### After Test
### After Tests
<div id='js-teardown'>
```js
console.info('after the test');
const testCases = [
[[1, 2, 3, 4, 5], ['a', 'b', 'c', 'd', 'e']],
[[1, 2, 3, 4, 5], ['a', 'b', 'c', 'd']],
[[1, 2, 3], ['a', 'b', 'c', 'd', 'e']],
[['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5]],
[['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4]],
[['a', 'b', 'c'], [1, 2, 3, 4, 5]]
];
const res = [
{ 1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e' },
{ 1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: undefined },
{ 1: 'a', 2: 'b', 3: 'c' },
{ a: 1, b: 2, c: 3, d: 4, e: 5 },
{ a: 1, b: 2, c: 3, d: 4, e: undefined },
{ a: 1, b: 2, c: 3 }
];
```
</div>
@@ -68,6 +87,12 @@ console.info('after the test');
<section id='solution'>
```js
// solution required
function arrToObj (keys, vals) {
return keys.reduce((map, key, index) => {
map[key] = vals[index];
return map;
}, {});
}
```
</section>