FreeCodeCamp - Arguments Optional - Need Help

Hello, to make this exercice work, it is important to store the value from my …args in a variable ?
I can’t use arrayArgs[0] and arrayArgs[1] ? i tried and it didn’t work.
So i did my firstValue and secondValue variable…
I just need clarification on this:

/*
Link: https://beta.freecodecamp.org/en/challenges/intermediate-algorithm-scripting/arguments-optional
*/

function addTogether( ...args ) {
	const arrayArgs = [...args];
	const firstValue = arrayArgs[0];
	const secondValue = arrayArgs[1];
	const arrayArgsL = arrayArgs.length;
	
	if( ( arrayArgsL == 2 ) && ( Number.isInteger( firstValue ) == true ) && ( Number.isInteger( secondValue ) == true  ) ) {
		return firstValue + secondValue;
		
	}else if( ( Number.isInteger( firstValue ) == false ) && ( Number.isInteger( secondValue ) == false ) ) {
		return undefined;
	
	}else if( arrayArgsL == 1 ) {
		return function( b ) {
			if( ( Number.isInteger( firstValue ) == true ) && ( Number.isInteger( b ) == true ) )  {
				return firstValue + b;
			}else {
				return undefined;
			}
		};
	}
};

console.log( addTogether( 2, 3 ) );
console.log( addTogether(2)(3) );
console.log( addTogether("http://bit.ly/IqT6zt") );
console.log( addTogether(2, "3") );
console.log( addTogether(2)([3]) );

Thx you !!

ps: If you have any idea concerning this exercice too:
https://forum.freecodecamp.org/t/need-help-smallest-common-multiple/161290/9

Hello, well every time you see a firstValue && secondValue, i used arraysArgs[0] or arraysArgs[1] :slight_smile:

But, how function like this one function()() is called exactly ? I know about rest argument but not this and i didn’t saw it, if i remember correctly, anywhere in all my courses (FCC and elsewhere).

Ok, thanks you !
But this method is not really used ? is it ?