Interview Whiteboard question

PHOTO EMBED

Sun Jan 28 2024 17:24:54 GMT+0000 (Coordinated Universal Time)

Saved by @Marcelluki

/* write the function getProperty(), which takes two arguments: 
an object and a path to the property, which you need to get from the object. 
the path to the property is a string of keys separated by dots. */

function getProperty(obj, path) {
  // write your code here
}

const object = {
  one: 1,
  two: {
    three: 3
  },
  four: 4
};

getProperty(object, 'one'); // 1
getProperty(object, 'two.three'); // 3 
content_copyCOPY

https://tripleten.com/trainer/web/lesson/6d1bd52c-a911-4345-8745-a7aaee5ff9a9/