Merge pull request #2917 from Omid-Heidarzadeh/bugfix

Bugfix:binary-arrays/concat/solution
This commit is contained in:
Ilya Kantor 2022-04-14 06:27:17 +03:00 committed by GitHub
commit ddb2b10c07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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