Bugfix:binary-arrays/concat/solution

This commit is contained in:
Omid Heidarzadeh 2022-03-15 22:55:51 +03:30
parent 2cca9a9d09
commit ae0a73fc1a

View file

@ -2,9 +2,9 @@ function concat(arrays) {
// sum of individual array lengths
let totalLength = arrays.reduce((acc, value) => acc + value.length, 0);
if (!arrays.length) return null;
let result = new Uint8Array(totalLength);
if (!arrays.length) return result;
// for each array - copy it over result
// next array is copied right after the previous one