Hey there, I am stuck on this problem. I hope someone can help me :slight_smile:

Define a function called concat. The function should, when given two arrays, concatenate the arrays together.

My answer:-

function concat(x,y)
  let length = x.length + y.length;
   let z = [length];
   let pos = 0;
   for(let element of x){
   for(let element of y){
   return z ;

console.log(concat([1,2,3],[4,5,6,7]))                      //OUTPUT should be [1,2,3,4,5,6,7]

can anyone tell me what am i doing wrong and how to fix it ?

What is the question? I ran your code, and got the desired output

Are there any restrictions in regards to modifying the array?

you got the desired output? I ran it on codecademy’s terminal and nothing came up. anyways i fixed the problem. but that is really surprising. :slight_smile:

The code seems more complex then needed, but I ran your code here:

JS Bin - Collaborative JavaScript Debugging

and things where fine. I wouldn’t use codecademy if you don’t do something exercise related, codecademy isn’t really designed for it, and there are so many online sandboxes (jsbin, jsfiddle, repl, codepen and many more)