समस्या
हमें एक JavaScript फ़ंक्शन लिखना है जो 1-आधारित महीना इंडेक्स लेता है और तिमाही वापस करता है जिसमें महीना आता है।
उदाहरण
कोड निम्न है -
const month = 7;
const findQuarter = (month = 1) => {
if (month <= 3) {
return 1;
} else if (month <= 6) {
return 2;
} else if (month <= 9) {
return 3;
} else if (month <= 12) {
return 4;
}
};
console.log(findQuarter(month));
आउटपुट
कंसोल आउटपुट निम्न है -
3