Skip to content

Commit f9dc867

Browse files
authored
Created JavaScript File for Functions
1 parent fbf64f5 commit f9dc867

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Functions/main.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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.

0 commit comments

Comments
 (0)