Find out if any of the numbers in the array are divisible by three. If there is at least one, return true, if not, return false.
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];
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,3,156,160,164,168,172,176,180,184,188,192,196,200,204];
_.some can do this very easily.
Both the above arrays will return true. However, this one should return false:
var testArray3 = [2,1,4,5,7,8,10,11,13,14,16,17,19,20,22,23,25,26,28];
No comments:
Post a Comment