Sha256: 16b817c2d31d8ccbd27f1a28f9cf906b6a59315d197bc24ddea649b8b7656d51

Contents?: true

Size: 451 Bytes

Versions: 68

Compression:

Stored size: 451 Bytes

Contents

var Flattener = function () { };

Flattener.prototype.flatten = function (unflattenedArray, inputFlattenedArray) {
  var self = this;
  var flattenedArray = inputFlattenedArray || [];
  unflattenedArray.forEach(function (element) {
    if (Array.isArray(element)) {
      self.flatten(element, flattenedArray);
    } else if (element !== null) {
      flattenedArray.push(element);
    }
  });
  return flattenedArray;
};

module.exports = Flattener;

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.118 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.117 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.116 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.115 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.114 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.113 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.111 tracks/javascript/exercises/flatten-array/example.js