timoxley / functional-javascript-workshop

A functional javascript workshop. No libraries required (i.e. no underscore), just ES5.
2.06k stars 441 forks source link

using every and some #177

Open hmntptwl opened 7 years ago

hmntptwl commented 7 years ago

I did it this way

function checkUsersValid(goodUsers) {
      return function allUsersValid(submittedUsers) {
var a=goodUsers.map(function(v){
    return v.id;
})
var b=submittedUsers.map(function(x){
    return x.id;
})
return b.every(function(z){
  return a.indexOf(z) > -1;
})

      };
    }

My solution to Basic :Call was like this

   function duckCount(...arg) {
       var c = 0 ;
      [...arg].forEach(function(v,i){
    if(Object.prototype.hasOwnProperty.call(arg[i],'quack'))  
           c++;
       })

     return c;
    }