0

Below is the code I unsuccessfully try to run in the console of chrome. Now the code of which looks like this and does not actually work.

Test.provide = Test.data = function arraaays() {
const c = [];

for (let i = 0; i < Math.max(a.length, b.length); i++) {
    if (a[i] !== undefined) {
        c.push(a[i]);
    }

    if (b[i] !== undefined) {
        c.push(b[i]);
    }
}

console.log(c);
}

The code itself should interact with two arrays that are in Test.data and create a new one of this type on their basis

a: ['a', 'b', 'c'] //first array
b: ['d', 'e'] //second array
c: ['a', 'd', 'b', 'e', 'c'] // new array
trigun117
  • 629
  • 6
  • 21

1 Answers1

0
function arry(a, b) {
var c = [];

for (let i = 0; i < Math.max(a.length, b.length); i++) {
    if (a[i] != undefined) {
        c.push(a[i]);
    }

    if (b[i] != undefined) {
        c.push(b[i]);
    }
}
return c;
}
Test.provide = arry(Test.data.a, Test.data.b);
trigun117
  • 629
  • 6
  • 21