Intermediate Algorithm Scripting - Arguments Optional

Hello everyone, i need someone to explain to me why in FCC solution they wrote first and _$Second in parentheses?

if (typeof (first) === “number” ) 
If (typeof (_&Second) === “number) return first + _$Second;

I WROTE THE SOLUTION LINK BELOW, AND I WROTE THE FULL CODE

function addTogether() {
const [first, _$Second] = arguments;
if (typeof (first) === “number” ) {
If (typeof (_&Second) === “number) return first + _$Second;
If (arguments.length === 1 ) return (_$Second) => addTogether(first, _$Second);
}}

addTogether(2,3);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Safari/605.1.15

Challenge Information:

Intermediate Algorithm Scripting - Arguments Optional

  • are you sure?! cause im not seeing it from their provided three solutions!!
  • also you can name a variable in many ways!! you can look it up about “naming convention” of variables

happy coding :slight_smile:

They wrote second, i accidentally wrote it like that, but that’s was not my point.

MY POINT IS.

why did they wrote typeof (first)? Why did they put the variable inside parentheses

  • you dont have to!! you can simply just write as such typeof first === 'something'

happy coding :slight_smile:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.