समस्या
हमें एक जावास्क्रिप्ट फ़ंक्शन लिखना है जो 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