+ 1

Use of parameters in js?

What is the use of parameters and how do they work?

31st Dec 2017, 9:18 PM
Avyaansh
Avyaansh  - avatar
1 Odpowiedź
+ 3
think of them as input for a function so you could have a function that takes in two numbers (as parameters) and returns the average. the syntax would look like: function avg(var x, var y) { return x + y / 2; } //to call avg: var Foo = avg(10, 20);
31st Dec 2017, 9:38 PM
Jordan Chapman
Jordan Chapman - avatar