ES6: Write Arrow Functions with Parameters

Can someone help me understand why my answer to this challenge passed, i think i understand the concept of this challenge , however i don’t understand how i ended up with the answer in my code ? my understanding is that the challenge was to combine the two arrays into one, what i don’t understand is how i ended up with 43 in my array.

`const myConcat = (arr1, arr2) => arr1 + arr2;
// test your code
console.log(myConcat([1, 4], [3, 4, 5]));

1,43,4,5`

When the + operator is used on two arrays, they are converted first to strings, then the resulting strings are concatenated. [1, 4] becomes the string "1,4", and [3, 4, 5] becomes "3,4,5".

"1,4" + "3,4,5" becomes "1,43,4,5".

3 Likes

Thank you very much for the explanation! makes perfect sense now.