Skip to content

Commit 1355b63

Browse files
committed
about function
1 parent 856dfb8 commit 1355b63

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

functions.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// 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+
function function_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+
function Myname(){
16+
console.log("a");
17+
console.log("b");
18+
console.log("h");
19+
console.log("i");
20+
return 0;
21+
}
22+
23+
// Myname();
24+
25+
// another example
26+
27+
function addtwo_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+
return num1+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+
const result=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
42+
43+
44+
// loginuser massage
45+
function loginuser_massage(username){
46+
return `${username} just logged in`;
47+
}
48+
49+
const userm=
50+
console.log(loginuser_massage("ravi674"))

0 commit comments

Comments
 (0)