Skip to content

Misleading description #3350

@smarshy

Description

@smarshy

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'});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions