[Solved] Better way to write this javascript filter code? [closed]

Depends on why you’re doing what you’re doing with this code. If you’re just trying to golf it, one way to make it shorter is to remove the definitions of the lambdas and call them inline. Something like below var numbers = [0,1,2,3,4,5,6,7,8,9]; var greaterthanvalues = ((numbers, value) => numbers.filter((number) => number > value ))(numbers, … Read more

[Solved] array cross-over loop in javascript

This is a functional ES6 approach. let variants = [{ variantName: “Size”, variantItems: [ “XL”, “MD”, “SM” ] }, { variantName: “Color”, variantItems: [ “Red”, “Blue” ] }]; let crossJoined = new Array(variants.reduce((product, variant) => (product * variant.variantItems.length), 1)) .fill(0) .reduce(crossJoin => { crossJoin.data.push(crossJoin.currentIndexes.map((itemIndex, variantIndex) => `${variants[variantIndex].variantName}: ${variants[variantIndex].variantItems[itemIndex]}`).join(“, “)); let incrementableIndex = variants.length – crossJoin.currentIndexes … Read more