Hey all I am trying to solve this.
I have an open that contains a nested array of ranges.
let test = {ranges: [[01, 10], [11, 100], [1000, 10001]]};
function characterCount(script) {
return test.ranges.reduce((count, [from, to]) => {
return count + (from - to);
}, 0);
}
console.log(test.ranges.reduce((a, b) => {
// console.log("a", a, "b", b);
console.log("a", a, "b", b);
return characterCount(a) < characterCount(b) ? b : a;
}));
the result should be [1000, 10001];
Any help appreciated I finding this very tricky.
Top comments (1)
I think I got it