Beginner

Make Decisions Using the Switch Statement

Description

In this challenge, you will write a function that takes a string representing a day of the week and returns whether it's a weekday or a weekend.

You should use a switch statement, which is a powerful control structure in JavaScript that allows you to evaluate an expression and execute different code blocks based on its value.

The switch statement is useful when you have multiple conditions that depend on the same variable, making the code more readable and efficient compared to multiple if-else statements.

The function should: Return "Weekday" if the input is Monday to Friday. Return "Weekend" if the input is Saturday or Sunday. Return "Invalid day" for any other input.

Instructions

Write a function called getDayType that takes one parameter: day - a string representing the day of the week (e.g., "Monday", "Saturday").

The function should return a string indicating whether the day is a weekday or weekend, or "Invalid day" if an unknown value is given. The input will always be a string, but it may contain different capitalizations. Handle this by normalizing the case.

Example usage:

// Expected output: "Weekday"
getDayType("Saturday");
// Expected output: "Weekend"
getDayType("holiday");
// Expected output: "Invalid day"
getDayType("FRIDAY");
// Expected output: "Weekday"

window code 2Test Cases

Input:

"Monday"

Expected Output:

"Weekday"