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.180 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.179 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.178 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.177 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.176 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.175 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.174 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.173 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.172 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.171 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.170 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.169 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.167 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.166 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.165 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.164 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.163 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.162 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.161 tracks/javascript/exercises/flatten-array/example.js
trackler-2.2.1.160 tracks/javascript/exercises/flatten-array/example.js