0

There is a rule in JS: Never use arguments, opt to use rest syntax ... instead. Ok, let's try. I write:

let arr = [16, 'mother', 'kids'];

function concatenateAll(...arr) {
  return arr.join('');
}

But the output in the console doesn't satisfy the rule. Where is my mistake?

10
  • 4
    Did you call the function? concatenateAll(...arr)? Commented Jul 13, 2018 at 16:32
  • Can you post all of your code please? Commented Jul 13, 2018 at 16:33
  • 2
    Who did you think set this rule? arguments still works fine if you want to use it. Commented Jul 13, 2018 at 16:33
  • "the output in the console doesn't satisfy the rule" - you are not outputting anything to the console. And what rule would it satisfy? Commented Jul 13, 2018 at 16:34
  • 2
    Possible duplicate of Do rest parameters allow for optimization? Commented Jul 13, 2018 at 16:36

1 Answer 1

1

You did not call the function seems to be your problem.

let arr = [16, 'mother', 'kids'];

function concatenateAll(...arr) {
  return arr.join('');
}

console.log('Passing 3 individual arguments to the function returns: ', concatenateAll(...arr));

Sign up to request clarification or add additional context in comments.

1 Comment

This doesn't do the same thing.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.