Skip to content

Commit

Permalink
задача 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
osvetilka committed Feb 2, 2025
1 parent f015cbc commit b179882
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion 03-objects-arrays-intro-to-testing/1-create-getter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit b179882

Please sign in to comment.