JSFiddle - React, Tailwind, and code Playground

by Scott Kaye

JavaScript

const solution = (l,m,a=Array(12).fill(0),o=l.reduce((w,t,f)=>{a[~-m[f].split`-`[1]]+=t<0?1:0;return w + t;})) => {
	for(c of a)if(c<3)o-=5
	return o;
}

console.assert(solution([100, 100, 100, -10], ["2020-12-31", "2020-12-22", "2020-12-03", "2020-12-29"]) === 230);

console.assert(solution([180, -50, -25, -25], ["2020-01-01", "2020-01-01", "2020-01-01", "2020-01-31"]) === 25);

console.log(solution([180, -50, -25, -25], ["2020-01-01", "2020-01-01", "2020-01-01", "2020-01-31"]));