Pages

Friday, June 10, 2016

Code problem to solve with Javascript's underscore functions.

Determine whether every number in the array is divisible by 4.  The function you make should return true or false.


var testArray1 = [4,8,12,16,20,24,28,32,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204];

var testArray2 = [4,8,12,16,20,24,28,32,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,3,156,160,164,168,172,176,180,184,188,192,196,200,204];

testArray1 === true;

testArray2 === false;

I just used _.every.

No comments:

Post a Comment