-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.js
More file actions
39 lines (30 loc) · 942 Bytes
/
Copy pathfunction.js
File metadata and controls
39 lines (30 loc) · 942 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
27
28
29
30
31
32
33
34
35
36
37
38
39
// * functions
// methods = build-in functions
"amir".toLocaleLowerCase();
Math.random()
// ! Own functions
// function decoration syntax
function sum(num1, num2) {
if (num2 === undefined) {
return num1 + num1
}
return num1 + num2;
}
// console.log(sum(4, 1));
// function getUserNameFromEmail(email) {
// return email.slice(0, email.indexOf("@"));
// }
// console.log(getUserNameFromEmail("user@github.com"));
// const getUserNameFromEmail = function (email) {
// return email.slice(0, email.indexOf("@"));
// }
// console.log(getUserNameFromEmail("amir@github.com"));
const getUserNameFromEmail = (email) => {
return email.slice(0, email.indexOf("@"));
}
// console.log(getUserNameFromEmail("developer@github.com"));
const toProperCase = (name) => {
return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
}
console.log(toProperCase("september"));
// *function provided reusable code!