Understanding JavaScript syntax

Tell us what’s happening:
Describe your issue in detail here.

Hi everyone, I semi understand this challenge and I’m passing no problem. My question relates to how the function knows whether to use a number as opposed to a letter.

If I said processArg(L) would it attempt to add 3 to L and divide by 5?

I guess what I’m really asking is… Is the (num) structurally important to the function in that it tells javascript to expect a number or can any word be placed inside the parenthesis?

Your code so far

// Setup
let processed = 0;

function processArg(num) {
return (num + 3) / 5;
}

// Only change code below this line

processed = processArg(7)

console.log(processed);
Browser info
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36

Challenge: Assignment with a Returned Value

Link to the challenge:

Wait I think I’ve got it… (slowly dawning on me face)

You can try it yourself in your browser console, etc.

function processArg(num) {
  return (num + 3) / 5;
}

processArg("L") // NaN

image


The answer is no.

The name of your arguments or variables can be anything really. But, because of that fact you should prefer to use descriptive names.

2 Likes

Got you… Great answer! :slight_smile:

To be very specific, in the above example (num + 3) would evaluate to the string "L3", and then attempt to get divided by 5, so we get NaN - not a number.