You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// fuction is a pakage which can we use again & again we need to create function onece then we can call that any where anytime by function name
2
+
3
+
// syntax of function
4
+
functionfunction_name(){
5
+
6
+
}
7
+
8
+
// here a example
9
+
// console.log("a");
10
+
// console.log("b");
11
+
// console.log("h");
12
+
// console.log("i");
13
+
// if we need to print this more times then we will need to write this again&again it is a long process but if we will put it in a package means in a function then we can call it eassyly by function name
14
+
15
+
functionMyname(){
16
+
console.log("a");
17
+
console.log("b");
18
+
console.log("h");
19
+
console.log("i");
20
+
return0;
21
+
}
22
+
23
+
// Myname();
24
+
25
+
// another example
26
+
27
+
functionaddtwo_number(num1,num2){//we we are creating function then which input we decide to get that will called parameter
28
+
console.log(num1+num2);
29
+
returnnum1+num2;
30
+
console.log("abhishek");//after give return forward code will not work that will called as unreachable code therefor we will give return in the end of function all code
31
+
32
+
}
33
+
34
+
// and which will give when call any fuction will called arguments
35
+
// addtwo_number(52,85) //if we will not give arguments then will get NaN here
36
+
37
+
// if we want to store function
38
+
constresult=addtwo_number(52,85)
39
+
// here we will see when we are doing console.log(result) then we will get undefined cause here function called and function performed but not return anything . so if we will call function then we code will perform which is in function but we will not get anything if we have not told what need to return
40
+
console.log(result);
41
+
// now we will get function return stored in result variable
0 commit comments