I was able to achieve the same result using the reduce method.
const some_tuples = [ [10, "Awesome"], [4, "Okay-ish"], [2, "Oh hell no"] ];
function combine_reducer(tuple_a, tuple_b) { return [ tuple_a[0] + tuple_b[0], tuple_a[1].concat(', ', tuple_b[1]) ] }
console.log(some_tuples.reduce(combine_reducer));
running this through node gave me: $ node combine_with.js [ 16, 'Awesome, Okay-ish, Oh hell no' ]
$ node combine_with.js [ 16, 'Awesome, Okay-ish, Oh hell no' ]
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I was able to achieve the same result using the reduce method.
const some_tuples = [
[10, "Awesome"],
[4, "Okay-ish"],
[2, "Oh hell no"]
];
function combine_reducer(tuple_a, tuple_b) {
return [
tuple_a[0] + tuple_b[0],
tuple_a[1].concat(', ', tuple_b[1])
]
}
console.log(some_tuples.reduce(combine_reducer));
running this through node gave me:
$ node combine_with.js
[ 16, 'Awesome, Okay-ish, Oh hell no' ]