File tree 3 files changed +18
-0
lines changed
3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -22,3 +22,4 @@ My Codewars solutions in various languages.
22
22
- [ Arguments to Binary addition (8 kyu)] ( https://www.codewars.com/kata/arguments-to-binary-addition ) [[ solution] ( https://github.com/PaulNoth/codewars/blob/master/arguments-to-binary-addition/solution.md )] [[ javascript] ( https://github.com/PaulNoth/codewars/blob/master/arguments-to-binary-addition/kata.js )]
23
23
- [ Mr. Freeze (8 kyu)] ( https://www.codewars.com/kata/mr-freeze ) [[ solution] ( https://github.com/PaulNoth/codewars/blob/master/mr-freeze/solution.md )] [[ javascript] ( https://github.com/PaulNoth/codewars/blob/master/mr-freeze/kata.js )]
24
24
- [ RGB To Hex Conversion (5 kyu)] ( https://www.codewars.com/kata/rgb-to-hex-conversion ) [[ solution] ( https://github.com/PaulNoth/codewars/blob/master/rgb-to-hex-conversion/solution.md )] [[ javascript] ( https://github.com/PaulNoth/codewars/blob/master/rgb-to-hex-conversion/kata.js )]
25
+ - [ flatten (5 kyu)] ( https://www.codewars.com/kata/flatten ) [[ solution] ( https://github.com/PaulNoth/codewars/blob/master/flatten/solution.md )] [[ javascript] ( https://github.com/PaulNoth/flatten/blob/master/rgb-to-hex-conversion/kata.js )]
Original file line number Diff line number Diff line change
1
+ function flatten ( ) {
2
+ let elements = [ ] ;
3
+ const args = [ ...arguments ] ;
4
+
5
+ for ( let i = 0 ; i < args . length ; i ++ ) {
6
+ const arg = args [ i ] ;
7
+ if ( arg && arg . constructor === Array ) {
8
+ elements = elements . concat ( flatten ( ...arg ) ) ;
9
+ } else {
10
+ elements . push ( arg ) ;
11
+ }
12
+ }
13
+ return elements ;
14
+ }
Original file line number Diff line number Diff line change
1
+ ### flatten()
2
+
3
+ Loot at the solution.
You can’t perform that action at this time.
0 commit comments