# How does: " function (num) "work?

Sorry if I´m being confused here.

1. I don´t yet understand why we use (num) in functions. Is that because a number or a numerical operation follows or just a name ?
2. Can the Number 7 be defined later in the function “processed = processArg(7);”
, be used previously in the calculation “(num + 3) / 5;”?

let processed = 0;
function processArg(num) {return (num + 3) / 5;}
processed = processArg(7);

processed should have a value of 2

Many thanks.

// Setup
let processed = 0;

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

// Only change code below this line
processed = processArg(7);

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

Challenge: Assignment with a Returned Value

‘num’ is just a descriptive name for the value you are passing into the function. It helps people who are looking at your code know what type of value the function expects to be passed in. But that name can be anything you want. That function can defined as:

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

It will still work just fine, but it’s pretty confusing when you want a number to be passed into it, don’t you think

When you pass a number in to the function:

processArg(7)

Then num takes the value of that number. So inside the function, num equals 7, and thus the function would be doing

return (7 + 3) / 5;
2 Likes

Now I understand (num) is just a convention name, that will take a value defined later.

I got confused because the value is defined later for a matematical calculation that took place in a function declared before.

Many thanks.

1 Like

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