Skip to content

Commit 36777cd

Browse files
author
DouglasHdezT
committed
Add: ArrowFunctons examples
1 parent d08c188 commit 36777cd

4 files changed

Lines changed: 61 additions & 0 deletions

File tree

2-ArrowFunctions/Example1.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use-strict'
2+
3+
/**
4+
* Sintaxis
5+
*/
6+
7+
function noArrowFunction(){
8+
console.log("This isn't an arrow function");
9+
}
10+
11+
const arrowFunction = () => {
12+
console.log("This is an arrow function");
13+
}
14+
15+
console.log("--------> noArrowFunction()");
16+
noArrowFunction();
17+
console.log("--------> arrowFunction()");
18+
arrowFunction();

2-ArrowFunctions/Example2.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
'use-strict'
2+
3+
/**
4+
* Sintax variations
5+
*/
6+
7+
//No parameters
8+
const af1 = () => {
9+
console.log("I don't recieved any parameter");
10+
}
11+
12+
//One parameter
13+
const af2 = name => {
14+
console.log("I recieved this name: " + name);
15+
}
16+
17+
//Many parameters
18+
const af3 = (name, age, gender) => {
19+
console.log(`Name: ${name}`);
20+
console.log(`Age: ${age}`);
21+
console.log(`Gender: ${gender}`);
22+
}
23+
24+
//Return values
25+
const af4 = (a, b) => {
26+
let result = a + b;
27+
28+
return result;
29+
}
30+
31+
//Single expresion
32+
const af5 = (a, b) => a + b;
33+
34+
console.log("-----> af1()");
35+
af1();
36+
console.log("-----> af2()");
37+
af2("Douglas");
38+
console.log("-----> af3()");
39+
af3("Pedro", 22, "Male");
40+
console.log("-----> af4()");
41+
console.log(af4(3 ,4));
42+
console.log("-----> af5()");
43+
console.log(af5(3 ,4));

0 commit comments

Comments
 (0)