## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
Chase
@DeviaVir
Hey @kolodny, are you purposely not saying anywhere that people are not allowed to use npm packages to solve the problems (aka, are they allowed)?
Moshe Kolodny
@kolodny
@deviaVir It kinda takes away from the challenge of it. I imagine things like flatten-promise would be really easy with https://www.npmjs.com/package/thunk-to-promise
Dan Revah
@danrevah
@kolodny Hey,I've just added a pull request with a simple test for the curry exercise. if it's hard to understand what I was trying to explain update me so I could send the solution to show you what I meant.
Moshe Kolodny
@kolodny
@danrevah I already merged it in, thanks
Dan Revah
@danrevah
@kolodny I'm currently working on a php version, mostly new exercises but I hope you don't mind that i'll take few exercises from here also. :)
Moshe Kolodny
@kolodny
sounds great! keep me updated on it's progress
Shilpa
@shilpa11
Hi Kolodny , I was trying out your exercises which by the way are great. But some how my tests are failing. I don't know where i am going wrong.

I have made a index.js file . And here is my code for that: function binarySearch (arr, value) {
var startIndex = 0;
var lastIndex = arr.length-1;
var middle = Math.floor((startIndex + lastIndex)/2);

while (arr[middle] != value && startIndex <= lastIndex) {
if (arr[middle] > value) {
lastIndex = middle - 1;
} else if (arr[middle] < value) {
startIndex = middle + 1;
}
middle = Math.floor((startIndex + lastIndex)/2);
}
return (arr[middle] != value ? -1 : middle);
}

Please let me know the steps to run this. I am running npm test command but all the tests are failing
Moshe Kolodny
@kolodny
@shilpa11 what happens when you try running it?
Shilpa
@shilpa11
Thanks for the reply. It was my bad. I didn't export the module at the top. It's working fine now. Earlier all the test cases were failing
Sid Syrus
@SidSyrus
I am trying to get solution for one of the challenge but having issues while running it through flip.js. Would you mind explaining how to do it?
Moshe Kolodny
@kolodny
@SidSyrus sure thing, you need to do something like this:
git checkout solutions
node flip.js once/index.js
cat once/index.js
cd once
npm test
Sid Syrus
@SidSyrus
@kolodny Thank you, appreciate it.
rainrunner88
@rainrunner88
thank you for posting helpful challenges
im a web development student at general assembly ny and they are really helpful
Ben Wallach
@benw91

Hi, I know that this is relatively old, but thanks for the helpful challenges!
I'm trying to solve the "flatten" challenge and I don't understand what I'm doing wrong. I checked my code in playcode.io and in jsbin and I get the expected [1,2,3,4,5] array, but the test you wrote says it gets [1,2,3,4]. This is my code:

function unpack(arr) {
if(!hasInternalArr(arr)) return arr;
var popped = arr.pop();
if(hasInternalArr(popped)) {
return arr.concat(unpack(popped));
}
else {
return arr.concat(popped)
}
}

function hasInternalArr(arr) {
if(!Array.isArray(arr)) return false;
return arr.some(function(curr) {
return Array.isArray(curr);
});
}
function flatten(arr) {
var toRet = [];
arr.map(function(curr) {
var unpacked = unpack(curr)
toRet = toRet.concat(unpacked);
});
}