let ans = 0; let plus = x => { x = String(x); while (x.length < 2) { x += "0" + x; } return Number(x[0]) + Number(x[1]); } for(let i = 1; i <= 12; i++) { let last = 31; if (i === 4 || i === 6 || i === 9 || i === 11) { last = 30; } else if (i === 2) { last = 28; } for (let j = 1; j <= last; j++) { if (i === plus(j)) { ans++; } } } console.log(ans);