Skip to content

Commit

Permalink
Solve garageScript#56, Lesson 2: write a function that takes in an ob…
Browse files Browse the repository at this point in the history
…ject (data), a function that takes in key/value, and returns a filtered object
  • Loading branch information
Alberto Lopez committed Oct 30, 2017
1 parent ea42297 commit baf88e6
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions test/filteredObject.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
const solution = require('../solutions/filteredObject.js');

const objA = { '5':"blah blah",
'name': "ho", 'zolo': "4thech"
const objA = {
'5':"blah blah",
'name': "ho",
'zolo': "4thech"
}

const objA1 = {
'town': "san jose",
'neighborhood': "downtown"
}

const objA2 = {
'stones': "row",
'microphone': "stage"
}

const funct = (k, v, objectC={}, i=0)=>{
if(i === k.length){
return objectC; } if(v[i].length > 3){ objectC[k[i]]=v[i]; }
return objectC;
}
if(v[i].length > 3){
objectC[k[i]]=v[i];
}
return funct(k, v, objectC, i+1);
}

Expand All @@ -22,4 +38,6 @@ const test = (object, functions, result, i=0)=>{
return test(object, functions, result, i+1);

}
test(objA, funct,{'5':"bl", 'zolo':"4thech"});
test(objA, funct,{'5':"blah blah", 'zolo':"4thech"});
test(objA1, funct,{'5':"bl", 'zolo':"4thech"});
test(objA2, funct,{'stones':"row", 'microphone':"stage"});

0 comments on commit baf88e6

Please sign in to comment.