ES6 symbols with objects Employee with following conditions

Viewed 5588

 let email =Symbol();
let Employee = {
  name : "rajesh",
  phone :9800000000,
  [email] : "rajesh@gmail.com"
};
let allKeys = {
  keyss : Reflect.ownKeys(Employee)
};
console.log(allKeys.keyss);
let privateKeys = {
  p : Object.getOwnPropertySymbols(Employee)
};
console.log(privateKeys.p);
let publicKeys = {
  pu : Object.getOwnPropertyNames(Employee)
};
console.log(publicKeys.pu)


module.exports = {Employee, allKeys, privateKeys, publicKeys}

**I tried this code in hacker rank for past few days but not passing, I cannot resolve it by my own can any one help me.. The question is:

Create an object Employee with properties:

name as "rajesh" phone as 9800000000, symbol "email" as "rajesh@gmail.com".

After creating the object, display:

All the keys of object "employee"

Only private keys (symbols)

Only public keys (non symbols)**

1 Answers
let email = Symbol();
let Employee = {
  name : "rajesh",
  phone :9800000000,
  [email] : "rajesh@gmail.com"
};

let allKeys = Reflect.ownKeys(Employee);
let privateKeys = Object.getOwnPropertySymbols(Employee);
let publicKeys =  Object.getOwnPropertyNames(Employee);

module.exports = {Employee, allKeys, privateKeys, publicKeys}
Related