given month as an input write a js program to find corresponding season using switch statment
input1
January
output1
winter
input2
may
output2
summer
input3
october
output3
autumn
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
const month = readLine();
/* Please do not modify anything above this line */
// Write your code here
}
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
const month = readLine();
// Write your code here
switch(month.toLowerCase()) {
case 'december':
case 'janyary':
case 'february':
return 'Winter'
case 'march':
case 'april':
case 'may':
return 'Spring'
case 'june':
case 'july':
case 'august':
return 'Summer'
case 'september':
case 'october':
case 'november':
return 'Autumn'
default:
return 'This month does not exist.'
}
}
Comments
Leave a comment