freeCodeCamp icon indicating copy to clipboard operation
freeCodeCamp copied to clipboard

Misleading description

Open smarshy opened this issue 11 years ago • 1 comments

Challenge Bonfire: Everything Be True has an issue. User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

Issue:The description states that we have to check if the property in the second argument is present for each object in the collection.However,this isn't sufficient.What you also require is that the values should match. The following code checks if the property in second arg is existing for each of the objects but not their values.As a result,it doesnt pass.

My code:

function every(collection, pre) {
  // Does everyone have one of these?
  var pre_prop;
  var obj1=1;

  if (typeof(pre) == 'object')
    { 
      pre_prop=Object.getOwnPropertyNames(pre);
    }
  else
    { 

      pre_prop=[];
      pre_prop.push(pre);
      obj1=0;
    }


   for (var i=0;i<collection.length;i++)
     {
       for (var j=0;j<pre_prop.length;j++)
         {
           if (!collection[i].hasOwnProperty(pre_prop[j]))
         {
           return false;
         }


         }

     }
  return true;
}

every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}],{'sex': 'female'});

smarshy avatar Sep 18 '15 17:09 smarshy

Closing this issue as https://github.com/FreeCodeCamp/FreeCodeCamp/pull/3620 is merged.

bugron avatar Oct 24 '15 16:10 bugron