Open kartamyshev opened 4 years ago
const student = { name : "David Rayy", sclass : "VI", rollno : 12 }; const newObj = {}; function changeKeysAndValues (from_obj, to_obj) { for (let key in from_obj) { let new_key = key; key = from_obj[key]; from_obj[key] = new_key; to_obj[key] = from_obj[key]; delete from_obj[key]; } return; } function displayTheObj (obj) { let print = " "; for (let key in obj) { print +=`${key} : ${obj[key]}, `; }; print = `[${print}]`; return print; }; changeKeysAndValues(student, newObj); alert(displayTheObj(newObj)); alert(displayTheObj(student));