Photo by Belinda Fewings on Unsplash
Self, I wish you knew this... (about JS function parameters)
1 min read
Above they're shown as
What they are?
How do they work?
Were they invented to diminish any bit of hope you had to one day understand JS?
All questions you have asked, all questions we're not answering today. Instead...
I wish you understood them as 'placeholders' sooner.
Why it would have helped you
Saved you time - no more 'long division'-type thinking needed.
Better understand the code as a whole - seeing them as placeholders free up your (already limited) mental bandwidth to see the forest rather than just a few trees.
Let me explain
parameterTwo as 'holding space' for what you want to 'pass' (as it's called...) into it. Then, whatever is done inside the function code to them (
parameterTwo) is done to the thing you'll pass into it.
In this case
2 & the code inside the function is the sum of the two parameters, i.e. 1 + 2 which gives you 3.
Hope this helps. I'll see you in the future.
You from the future