BIS601 Program 3

PROGRAM:

let student = {
    name: "John Doe",
    grade: 85,
    subjects: ["Math", "Science", "English"],
    
    
    displayInfo: function() {
        console.log(`Name: ${this.name}`);
        console.log(`Grade: ${this.grade}`);
        console.log(`Subjects: ${this.subjects.join(', ')}`);
    }
};

student.passed = student.grade >= 50;
student.displayInfo();

for (let key in student) {
    if (typeof student[key] !== 'function') {
        console.log(`${key}: ${student[key]}`);
    }
}

Step 4: To run program use below command:

  • Open the vscode integrated terminal through the menu by selecting and type the below command to run the program.
node index.js

OUTPUT:

Name: John Doe
Grade: 85
Subjects: Math, Science, English
name: John Doe
grade: 85
subjects: Math,Science,English
passed: true
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x