Home Reference Source Test Repository

lib/concat.js

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.concat = concat;
/**
 * The concatenation of all the elements of a list.
 *
 * @since v0.1.0
 * @param {Array} list
 * @return {Array}
 * @example
 *   concat([[4, 5, 6], [1, 2, 3]]) // => [4, 5, 6, 1, 2, 3]
 *
 *   concat(intersperse(' ', ['intersperse', 'is', 'a', 'fun', 'function', '!']))) // =>
 *     'intersperse is a fun function !'
 */
function concat(list) {
  return list.reduce(function (a, b) {
    return a.concat(b);
  });
}