Stuck on Use the Rest Operator with Function Parameters challenge

Stuck on Use the Rest Operator with Function Parameters challenge
0

#1

Can you paste the solution here with explanation in simple words.?
I’m stuck on this problem. Went through many similar queries but couldn’t find the right solution to crack this problem.
Please help @Klaudia


Use the Rest Operator with Function Parameters1
#2

Instead of requesting someone post a solution, why don’t you post what code you have tried so far on your own? We can review it and try to offer you suggestions and hints.


#3

const sum = (function() {
“use strict”;
return function sum(x, y, z) {
const args = [ x, y, z ];
return args.reduce((a, b) => a + b, 4);
};
})();
console.log(sum(1, 2, 3)); // 6

I’m stuck here.
Only the second condition is correct, the rest are all incorrect.
Help!


#4

The point of this challenge is to use rest operator and you are not doing it.
Look at the example

function howMany(...args) {
  return "You have passed " + args.length + " arguments.";
}
console.log(howMany(0, 1, 2)); // You have passed 3 arguments
console.log(howMany("string", null, [1, 2, 3], { })); // You have passed 4 arguments.

Also here you can check what exactly is rest operator to make sure which part you need to include in your code.

You changed the value to 4 so that you get good aswer to one task but I don’t think it’s proper way of doing it.