score:2

Accepted answer
const reference = ['prefix', 'suffix', 'student_email']
const obj = {
  'prefix':'John',
  'suffix':'Doe',
  'student_email':'johndoe23@rigly.org',
  'course_code':'PJ4004',
  'professor':'McMillian'
}

Object.keys(obj).forEach(i=>{
  if(reference.indexOf(i) === -1) delete obj[i];
});

console.log(obj);

Related Query

More Query from same tag