Num, param1, param2?

Hi, just learning Javascript for the 1st time.

When the lessons mention using param1, param2, num… are these actual terms within that language, or are they just made up placeholders for whatever variables will be placed when calling the function?

Ex: (in the lesson Passing Values to Functions with Arguments)

function testFun (param1, param2) {
console.log(param1, param2);

Where param1, param2 stay the same and we supply numbers when we call the functions - are “param” the generally accepted placeholders?

I replaced them with the word ‘duck’ (duck1 and duck2) and the function still worked - would that actually work while doing actual developing? Probably a moot question since we’ll be doing stuff beyond this when actually working(?).

I’m so sorry if I missed this in an earlier lesson. I did find this:
“any names can be used because they are local to the function in which they are declared” (see citation below).

This tells me that param and num are “made up,” and also tells me to just be consistent in whatever I use - unless there are industry standards? I also just want to verify that I’m understanding this correctly.

citation: [Parameters and Arguments (]
(Parameters and Arguments

Hi @nurseoquin !

The parameters are placeholders for the real values when you call the function.

When it comes to naming parameters, you want to pick names that make sense for the problem you are solving.

In the challenge you are working on, appropriate parameter names could be num1 and num2.

function functionWithArgs(num1, num2){
//some code here

Since we are dealing with numbers it makes sense to come up with parameter names that fit the problem.

As you found out, you could name it anything you wanted like duck1 or duck2 or x,y but that is not descriptive to the problem you are dealing with.

Whenever it comes to naming variables, functions and parameters you want to pick descriptive names.

Hope that helps!


hello @nurseoquin !

lets understand with example :
consider i want to calculate sum of 4 numbers but each time with different value
then i will use function , who will give me some of four numbers

ok lots of stuff talking , lets dive in

function sum(number1, number2,number3, number4){
        return console.log(number1+number2+number3+number4);
sum(1,2,3,4)              // output in console 10 
sum(1,1,1,1)     // output in console 4 
sum(2,2,2,2) // output in console 8

so here number1 ,number2, number3 , number4 are my parameters
and when i call my function at 4,5 ,6 lines with different values and that values are my arguments .

now here what are parameters : parameters are those who will take that value when i pass as an arguments . ok don’t worry i explain with example , in our first call sum(1,2,3,4) each of value will get replace with parameter like , 1 = number1 , 2 = number2 and … up to four .

long story short , parameters are those who will get replace with your arguments when you pass, and parameters name can be anything you want. arguments name can be anything you want , but always use meaning full name ,so whenever you read your code next time , you should be able to understand it .

1 Like

Thank you so much! This really helps - I know I’ll have a lot to fill in without any coding/computer background, but it’s an exciting journey so far! I’m cramming with YouTube videos, computer science lectures, and lots of coding.

Thank you again! :grinning_face_with_smiling_eyes:

1 Like

you can take cs50 , if you want , this course will explain you introduction and understanding of computer science .
and this course is 100% free developed by harvard university .
you can find it on .

Thank you for this! Just enrolled!

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