forked from garageScript/algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Solve garageScript#56, Lesson 2: write a function that takes in an ob…
…ject (data), a function that takes in key/value, and returns a filtered object
- Loading branch information
Alberto Lopez
committed
Oct 27, 2017
1 parent
5fac33d
commit e3f9d1e
Showing
2 changed files
with
6 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,4 @@ | ||
/* | ||
const objA = { | ||
'5':"blah blah", | ||
'name': "ho", | ||
'zolo': "4thech" | ||
} | ||
const funct = (k, v, objectC={}, i=0)=>{ | ||
if(i === k.length){ | ||
return objectC; | ||
} | ||
if(v[i].length > 3){ | ||
objectC[k[i]]=v[i]; | ||
} | ||
return funct(k, v, objectC, i+1); | ||
} | ||
*/ | ||
|
||
const filterObj = (obj, func)=>{ | ||
return func(Object.keys(obj), Object.values(obj)); | ||
} | ||
//console.log(filterObj(objA,funct)); | ||
module.exports = filterObj; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters