Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading description #3350

Closed
smarshy opened this issue Sep 18, 2015 · 1 comment
Closed

Misleading description #3350

smarshy opened this issue Sep 18, 2015 · 1 comment

Comments

@smarshy
Copy link
Contributor

smarshy commented Sep 18, 2015

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

@bugron
Copy link
Contributor

bugron commented Oct 24, 2015

Closing this issue as #3620 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants