0

So I have two function, one for plus one for minus, and both are same function (copy and pasted),

which means, both returns the same name.

When obtaining the result of function, how can I change its name?

const { finalResult, totalPermuteAndCountDone } = getNewNumberByPermuteAndCombinationMinus(newUp, result, 1, newList);
const { plusResult, plusCountDone} = getNewNumberByPermuteAndCombinationMinus(newUp, result, 1, newList);

console.log(plusResult);
console.log(finalResult);
console.log(totalPermuteAndCountDone);
console.log(plusCountDone);

The bottom (plusResult and plusCountDone) are returning as undefined, because it does not exists, the returned value for both function is

return { finalResult, totalPermuteAndCountDone };

I would like to change the destructure's name after returning instead of changing its in function.

Example

const { minusResult, minusCountDone } = getNewNumberByPermuteAndCombinationMinus(newUp, result, 1, newList);
const { plusResult, plusCountDone} = getNewNumberByPermuteAndCombinationMinus(newUp, result, 1, newList);
Wing Shum
  • 472
  • 6
  • 19

0 Answers0