PROBLEM 60
Medium

Days in Month

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#60

Given month number 1..12 for a non-leap year, print the number of days.

EXAMPLE

Example

Input
2
Output
28

LIMITS

Constraints

1 ≤ month ≤ 12
📖
LEARN Theory for this problem
+

### Days in Month

`if / else if / else` chooses a branch from boolean conditions. Comparisons such as `<`, `>=`, `===` and logical operators `&&`, `||`, `!` combine the exact rules that decide which output is valid.

💡
NEED HELP? Hints
+

['Translate every case from the statement into a boolean condition before writing branches.', 'Verify the accumulator initial value and both loop boundaries; this is where off-by-one errors most often appear.']

ANSWER Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let m = Number(input);
if ((m) === (2)) {
    console.log(28);
} else {
    if (((m) === (4)) || ((m) === (6)) || ((m) === (9)) || ((m) === (11))) {
        console.log(30);
    } else {
        console.log(31);
    }
}