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

Drop it : Test case 2 and 6 expect wrong return value from the function. #11864

Closed
pdhanoya opened this issue Nov 29, 2016 · 3 comments
Closed

Comments

@pdhanoya
Copy link

pdhanoya commented Nov 29, 2016

Challenge Drop it has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

function dropElements(arr, func) {
  // Drop them elements.
  var duplicateArr = [];
  for(var i = 0 ; i < arr.length; i++){
    if(func(arr[i])){
      duplicateArr.push(arr[i]);
    }
  }
  return duplicateArr;
}

dropElements([1, 2, 3], function(n) {return n < 3; });

Incorrect Test Cases
dropElements([0, 1, 0, 1], function(n) {return n === 1;}) should return [1, 0, 1] - actual return value [1, 1]

dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}) should return [3, 9, 2] - actual return value [3, 9]

@dhcodes
Copy link
Contributor

dhcodes commented Nov 29, 2016

@pdhanoya You're to drop the items in the array, starting with index 0 until the function becomes true, NOT to drop all the items in the array that do not make the function (second argument) true. I see how it could be misunderstood.

@erictleung
Copy link
Member

@pdhanoya as @dhcodes has pointed out, the instructions say to drop elements until the function is true.

Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.

Thus, the tests and instructions are consistent with each other. If you get stuck or have questions with a challenge in the future, please first ask questions to the Help Room. Happy coding!

@srini5
Copy link

srini5 commented Dec 17, 2016

I had the same query. Thanks for the clear answer.

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

4 participants