File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1+ // Why do we need a function?
2+
3+ //Suppose you have to add two numbers let say a and b.
4+ // Tehn you can simply add them by taking its value from the user and adding it by using a+b
5+ // But what if you have to add 50 sets of such numbers?
6+ // You will repeat the above steps 50 times, right?
7+ // That pretty much doable but what if you are given 1000 such sets of numbers?
8+ // You won't be repeating it for 1000 times right?
9+ // That's where function comes in picture
10+ // They will produce reusuable codes.
11+ // You just have to define it once and then you can reuse it wherever you want.
12+
13+
14+ // Basic Syntax of a function in JavaScript
15+
16+ function name ( parameter1 , parameter2 , parameter3 , ...) {
17+ //code that needs to be executed will go here
18+ }
19+
20+ // There is a difference between parameter and arguement.
21+ // Parameter are variables that are used to take a particular value
22+ // Argument is the value that yoou give to the function so that some operations can be done on them.
You can’t perform that action at this time.
0 commit comments