Write Arrow Functions with Parameters

Tell us what’s happening:

I was wondering if someone could help me understand this. I searched and I could not figure it out. I tried a few other things
var myConcat = () => concat(arr1).arr2;
{
“use strict”;

};
// test your code
console.log(myConcat([1, 2], [3, 4, 5]));

among others. Could someone please assist me in understanding this?

Your code so far


var myConcat = (arr1 => arr2);
 {
  "use strict";
  return arr1.concat(arr2);
};
// test your code
console.log(myConcat([1, 2], [3, 4, 5]));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/write-arrow-functions-with-parameters

1 Like
const myConcat = (arr1,arr2) =>  {
  "use strict";
  return arr1.concat(arr2);
};
// test your code
console.log(myConcat([1, 2], [3, 4, 5]));

see here we need to provide arguments to the arrrow function and we need to pass two arguments. ie. arr1 and arr2.
Remember to convert var to const.

2 Likes

Thank you. I am having a heck of a time learning this E6 stuff. I think I should start all over in the Javascript stuff.
Thank you!!!

1 Like

I used this, it seems to be a much simpler solution than what is given under “Get a Hint.” It also demonstrates a concept from the previous lesson ES6: Use Arrow Functions to Write Concise Anonymous Functions. With arrow function syntax, you don’t need to have a function body.

I want to make a contribution and change the hint section somehow…but I am not sure how to do that yet :-D. That’s a question for another thread though.

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

Hello Aaldea! I’m wondering if you ever did start over with the Javascript and if it helped? Because I’m having such a hard time as I did with the first section of Javascript and am debating on doing the same as I’m just not grasping it.