-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasswork.js
More file actions
47 lines (42 loc) · 1.3 KB
/
Copy pathclasswork.js
File metadata and controls
47 lines (42 loc) · 1.3 KB
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
const student = {
name : "john Doe",
age : 22 ,
courses : [ "maths",
"physics",
"computer sience"],
address :{
city : "new york",
zip :"10001"}
}
//1.
function displayName(person){
return person.name
}
console.log(displayName(student));
function displaySecondName(person){
return person.courses[1]
}
console.log(displaySecondName(student));
function displayZipCode(person){
return `Zip code: ${person.address["zip"]}`
}
console.log(displayZipCode(student))
//2.
function updateAge(newAge){
student.age = newAge;
return student.age;
}
console.log(updateAge(23));
module.exports = {displayName,displaySecondName,displayZipCode,updateAge,addNewGPA_value,getDetails}
// Add a new property GPA with a value of 3.8.
function addNewGPA_value(student , value){
student["GPA"] = value ;
return student["GPA"]
}
console.log(addNewGPA_value(student , 3.8));
// Add a method getDetails() that returns "John Doe is 23 years
// old and has a GPA of 3.8".
function getDetails(student){
return `${displayName(student)} is ${student["age"]} years old and has a GPA of ${student.GPA}`
}
console.log(getDetails(student))