Reusing parameter with same name in different functions

Hi guys,

Hope you are all well :slight_smile:

I noticed in Javascript, across the exercises, that you could assign a parameter with the same name to different functions, as placeholder for different values from different arrays or data source.

Can you confirm that it’s fine because the parameter would only exist in the scope of its function?
For example can I use the word “param1” as a parameter across 10 different functions, as long as it’s not used twice in the same function?

So far it hasn’t given me any error message, but it would be great to get clarification.


well, there is a difference between fine and technically possible. Yes, its possible to use the same parameter name several times, given parameters have local scope.

But i wouldn’t define it as fine, function names, variable names, parameters and so forth should have logic names, this makes the code so much more understandable and easier to read.

Hi Stetim,

Makes sense, thanks for your answer.


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