-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFunctions2.js
More file actions
26 lines (21 loc) · 793 Bytes
/
Functions2.js
File metadata and controls
26 lines (21 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*****************************
* Function Statements and Expressions
*/
// Function declaration
// function whatDoYouDo(job, firstName) {}
// Function expression
const whatDoYouDo = (job, firstName) => {
switch (job) {
case 'teacher':
return firstName + ' teaches kids how to code';
case 'driver':
return firstName + ' drives a cab in Lisbon.'
case 'designer':
return firstName + ' designs beautiful websites';
default:
return firstName + ' does something else';
}
}
console.log(whatDoYouDo('teacher', 'John')); // John teaches kids how to code
console.log(whatDoYouDo('designer', 'Jane')); // Jane designs beautiful websites
console.log(whatDoYouDo('retired', 'Mark')); // Mark does something else