Skip to content

Commit 0752e63

Browse files
authored
Functions in JavaScript
1 parent c9e9410 commit 0752e63

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

functions.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Functions in JavaScript
2+
3+
// A function may take some arguments and may not take some arguments
4+
5+
// A function without arguments
6+
function hello() {
7+
console.log("This is a function which is not taking any argument");
8+
console.log("HELLO !");
9+
}
10+
11+
console.log(hello()); //Calling the hello() function
12+
13+
// A function with arguments
14+
// A function which take arguments may or may not return a value
15+
// A function can return a only a single value at a time
16+
17+
let a;
18+
let b;
19+
let c;
20+
function add(a, b) {
21+
console.log("This function adds two values passed to it");
22+
return a + b;
23+
}
24+
25+
c = add(21, 22);
26+
console.log(c);

0 commit comments

Comments
 (0)