--- title: Element-wise operations id: 599c333915e0ea32d04d4bec challengeType: 5 videoUrl: '' localeTitle: Элементные операции --- ## Description

Реализуйте основные матричные матричные и скалярно-матричные операции.

Воплощать в жизнь:

:: * дополнение

:: * вычитание

:: * умножение

:: * раздел

:: * возведение в степень

Первым параметром будет операция, которая должна быть выполнена, например: «m_add» для добавления матрицы и «s_add» для скалярного добавления. Второй и третий параметры будут представлять собой матрицы, на которых должны выполняться операции.

## Instructions undefined ## Tests
```yml tests: - text: operation - это функция. testString: 'assert(typeof operation === "function", "operation is a function.");' - text: 'operation("m_add",[[1,2],[3,4]],[[1,2],[3,4]]) должны вернуться [[2,4],[6,8]] .' testString: 'assert.deepEqual(operation("m_add", [[1, 2], [3, 4]], [[1, 2], [3, 4]]), [[2, 4], [6, 8]], "operation("m_add",[[1,2],[3,4]],[[1,2],[3,4]]) should return [[2,4],[6,8]].");' - text: 'operation("s_add",[[1,2],[3,4]],[[1,2],[3,4]]) должны возвращать [[3,4],[5,6]] .' testString: 'assert.deepEqual(operation("s_add", [[1, 2], [3, 4]], 2), [[3, 4], [5, 6]], "operation("s_add",[[1,2],[3,4]],[[1,2],[3,4]]) should return [[3,4],[5,6]].");' - text: 'operation("m_sub",[[1,2],[3,4]],[[1,2],[3,4]]) должны возвращать [[0,0],[0,0]] .' testString: 'assert.deepEqual(operation("m_sub", [[1, 2], [3, 4]], [[1, 2], [3, 4]]), [[0, 0], [0, 0]], "operation("m_sub",[[1,2],[3,4]],[[1,2],[3,4]]) should return [[0,0],[0,0]].");' - text: 'operation("m_mult",[[1,2],[3,4]],[[1,2],[3,4]]) должны возвращать [[1,4],[9,16]] .' testString: 'assert.deepEqual(operation("m_mult", [[1, 2], [3, 4]], [[1, 2], [3, 4]]), [[1, 4], [9, 16]], "operation("m_mult",[[1,2],[3,4]],[[1,2],[3,4]]) should return [[1,4],[9,16]].");' - text: 'operation("m_div",[[1,2],[3,4]],[[1,2],[3,4]]) должны возвращать [[1,1],[1,1]] .' testString: 'assert.deepEqual(operation("m_div", [[1, 2], [3, 4]], [[1, 2], [3, 4]]), [[1, 1], [1, 1]], "operation("m_div",[[1,2],[3,4]],[[1,2],[3,4]]) should return [[1,1],[1,1]].");' - text: 'operation("m_exp",[[1,2],[3,4]],[[1,2],[3,4]]) должны вернуться [[1,4],[27,256]] .' testString: 'assert.deepEqual(operation("m_exp", [[1, 2], [3, 4]], [[1, 2], [3, 4]]), [[1, 4], [27, 256]], "operation("m_exp",[[1,2],[3,4]],[[1,2],[3,4]]) should return [[1,4],[27,256]].");' - text: 'operation("m_add",[[1,2,3,4],[5,6,7,8]],[[9,10,11,12],[13,14,15,16]]) должен возвращать [[10,12,14,16],[18,20,22,24]] .' testString: 'assert.deepEqual(operation("m_add", [[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], [13, 14, 15, 16]]), [[10, 12, 14, 16], [18, 20, 22, 24]], "operation("m_add",[[1,2,3,4],[5,6,7,8]],[[9,10,11,12],[13,14,15,16]]) should return [[10,12,14,16],[18,20,22,24]].");' ```
## Challenge Seed
```js function operation (op, arr1, arr2) { // Good luck! } ```
## Solution
```js // solution required ```