Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
42 lines (29 loc) · 1.61 KB
/
Copy pathscript.js
File metadata and controls
42 lines (29 loc) · 1.61 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
// 1. Define a variable named `students` and assign a blank object to it.
let students = {};
// 2. Add a key of the value of variable `studentName` in the object created above with the value of your name.
students.studentName = "Rockey";
// 3. Using `console.log` log the value of `studentName` key from the `students` object
console.log(students.studentName);
// 4. Add a another key of the value of variable `batch` in the object with the value of 16.
students.batch = 16;
// 5. Using `console.log` log the value of `batch` key from the `students` object
console.log(batch);
// 6. Add another key in the object with the value of the variable `isAdult`. The value of the key should be `true/false`
students.isAdult = "true";
// 7. Using `console.log` print the value of `isAdult` key from the `students` object
console.log(isAdult);
// 8. Add a another key of `42` to the object with a value of `The answer to the meaning of life`.
students["42"] = "The answer to the meaning of life";
// 9. Using `console.log` print the value of key `42` from the `students` object
console.log(students[42]);
// 10. Check the length of object named `students`.
console.log(students.length);
// 11. Can you define a key of `let or var` in any object? Reason.
yes, we can define `let or var` in Object.
// 12. Delete the `isAdult` property from the object `students`. Also, print the object before or after deleting the property
console.log(students);
delete students.isAdult;
console.log(students);
// 13. Update the value of the key batch in the object `students` and print it using `console.log`
students.batch = 10;
console.log(students.batch);