diff --git a/03-objects-arrays-intro-to-testing/1-create-getter/index.js b/03-objects-arrays-intro-to-testing/1-create-getter/index.js index 9e9ac0c..15494dc 100644 --- a/03-objects-arrays-intro-to-testing/1-create-getter/index.js +++ b/03-objects-arrays-intro-to-testing/1-create-getter/index.js @@ -4,9 +4,10 @@ * @returns {function} - function-getter which allow get value from object by set path */ export function createGetter(path) { - const arr = path.split('.'); + const arr = path.split('.'); return function(obj) { + if (!obj.hasOwnProperty(arr[0])) return ; return arr.reduce((accum, item)=> accum.hasOwnProperty(item) ? accum[item] : undefined, obj)