Issue with Strict Mode

Tell us what’s happening:
Hello,
I have solved this challenge very well but by removing strict mode from the code.
But I have not been able to understand Why with “use strict”; console did not show the concatenated arrays.

Is this because strict mode needs me to declare the parameters (arr1,arr2) inside the function?
I did try to put this ( let arr1; let arr2;) just to check if that works but it doesnt.
What could be the problem?

Thankyou.

Your code so far


const myConcat = (arr1, arr2) => 
  "use strict";
  
   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/76.0.3809.100 Safari/537.36.

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

You’ve missed the curly brackets and the return off the function, that’s why it doesn’t work.

If the result is a single expression, you can elide the brackets and the return:

const someFunction = (args) => /* oneLine */;

const add = (a, b) => a + b;

If it isn’t, you can’t, same as a normal function:

const someFunction = (args) => {
  doSomething
  return something
}

This is what you’ve actually written:

const myConcat = (arr1, arr2) => "use strict";

That bit doesn’t do anything (if it doesn’t error)

1 Like

Got It.
Thankyou So Much!

1 Like