-
Notifications
You must be signed in to change notification settings - Fork 0
/
kata.js
39 lines (32 loc) · 1.06 KB
/
kata.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// #1
// function arrAdder(arr) {
// let string = Array.from(arr[0]);
// for (let i = 1; i < arr.length; i++) {
// for ( let k = 0; k < arr[i].length; k++) {
// string[k] += arr[i][k] }
// }
// return string.join(' ');
// }
// #2
const arrAdder = a => a[0].map((_, i) => a.map(r => r[i]).join('')).join(' ');
console.log(arrAdder([
['J', 'L', 'L', 'M'],
['u', 'i', 'i', 'a'],
['s', 'v', 'f', 'n'],
['t', 'e', 'e', '']
]))
//"Just Live Life Man"
console.log(arrAdder([
['T', 'M', 'i', 't', 'p', 'o', 't', 'c'],
['h', 'i', 's', 'h', 'o', 'f', 'h', 'e'],
['e', 't', '', 'e', 'w', '', 'e', 'l'],
['', 'o', '', '', 'e', '', '', 'l'],
['', 'c', '', '', 'r', '', '', ''],
['', 'h', '', '', 'h', '', '', ''],
['', 'o', '', '', 'o', '', '', ''],
['', 'n', '', '', 'u', '', '', ''],
['', 'd', '', '', 's', '', '', ''],
['', 'r', '', '', 'e', '', '', ''],
['', 'i', '', '', '', '', '', ''],
['', 'a', '', '', '', '', '', '']]));
// "The Mitochondria is the powerhouse of the cell"