forked from mrhm-dev/full-stack-army
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.js
More file actions
49 lines (41 loc) · 976 Bytes
/
function.js
File metadata and controls
49 lines (41 loc) · 976 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
40
41
42
43
44
45
46
47
48
49
const student1 = {
firstName: 'Maruf',
lastName: 'Sarker',
email: 'maruf@example.com',
age: 27,
attend: true
}
const student2 = {
firstName: 'Asif',
lastName: 'Sarker',
email: 'asif@example.com',
age: 27,
attend: true
}
const student3 = {
firstName: 'Lisan',
lastName: 'Sarker',
email: 'lisan@example.com',
age: 27,
attend: true
}
const allStudents = [student1, student2, student3]
allStudents.forEach(item => {
console.log('Fullname: ' + item.firstName + " " + item.lastName)
})
// function with error handling
function nameOfTheFunction(name){
if(!name){
console.log('Please provide your name');
}else{
console.log("Hello", name)
}
}
nameOfTheFunction("Maruf")
nameOfTheFunction("Sakib")
nameOfTheFunction()
// generate random number
const generateRandomNumber = (min,max) => {
return Math.floor(Math.random()*(max-min+1)+min);
}
console.log(generateRandomNumber(5, 10))