JenMorgan / js-learning

0 stars 0 forks source link

Write a JavaScript program to delete the rollno property from the object from #20. Also print the object before or after deleting the property #21

Open kartamyshev opened 4 years ago

JenMorgan commented 4 years ago
const student = {
    name : "David Rayy",
    sclass : "VI",
    rollno : 12 
  };

function displayTheKeys (obj) {
    let print = " ";
    for (let key in obj) {
        print +=`'${key}', `;
    };
    print = `[${print}]`;
    return print;
};

function deleteTheKey (obj, key) {
    delete obj[key];
};

deleteTheKey(student, "rollno");
const print = displayTheKeys(student);
alert(print);