© Yogesh Suryawanshi
© Yogesh Suryawanshi
© Yogesh Suryawanshi
© Yogesh Suryawanshi

Switch Case Examples

Learn how to use switch statements for multiple conditions.

रोजच्या जीवनातील उदाहरणे (Real Life Examples in Marathi)

1. आठवड्याचे दिवस आणि काय करायचे?

let आजचादिवस = "सोमवार"; switch(आजचादिवस) { case "सोमवार": console.log("शाळेला जायचे 🏫"); break; case "रविवार": console.log("सुट्टी आहे! 🎮"); break; case "शनिवार": console.log("अर्धा दिवस शाळा 📚"); break; default: console.log("नेहमीप्रमाणे शाळा 📝"); }

2. खाऊ काय करायचा?

let वार = "गुरुवार"; switch(वार) { case "सोमवार": console.log("पोहे 🍚"); break; case "गुरुवार": console.log("पुरणपोळी 🥮"); break; case "रविवार": console.log("बिर्याणी 🍛"); break; default: console.log("दाल-भात 🍚"); }

1. Simple Switch

let day = 1; switch(day) { case 1: console.log("Monday"); break; case 2: console.log("Tuesday"); break; default: console.log("Another day"); }

Result: Select a day

2. Grouped Cases

let month = "Jan"; switch(month) { case "Dec": case "Jan": case "Feb": console.log("Winter"); break; case "Mar": case "Apr": case "May": console.log("Spring"); break; default: console.log("Another season"); }

Result: Select a month

3. Grade Calculator

let grade = "A"; switch(grade) { case "A": console.log("Excellent!"); break; case "B": console.log("Good job!"); break; case "C": console.log("Passed"); break; default: console.log("Try again"); }

Result: Select a grade

4. Traffic Light

let light = "red"; switch(light) { case "red": console.log("Stop!"); break; case "yellow": console.log("Caution!"); break; case "green": console.log("Go!"); break; default: console.log("Invalid light"); }

Result: Select a light

Design and developed by Yogesh Suryawanshi