Day of Week Namer - Problem
Given a number between 1 and 7 (inclusive), return the corresponding day of the week name.
Mapping:
- 1 →
"Monday" - 2 →
"Tuesday" - 3 →
"Wednesday" - 4 →
"Thursday" - 5 →
"Friday" - 6 →
"Saturday" - 7 →
"Sunday"
For any input outside the range 1-7, return "Invalid".
Note: This problem focuses on conditional logic and input validation.
Input & Output
Example 1 — Valid Weekday
$
Input:
dayNumber = 3
›
Output:
Wednesday
💡 Note:
Input 3 corresponds to Wednesday in the week mapping (1=Monday, 2=Tuesday, 3=Wednesday, etc.)
Example 2 — Weekend Day
$
Input:
dayNumber = 7
›
Output:
Sunday
💡 Note:
Input 7 corresponds to Sunday, the last day in our 1-7 mapping system
Example 3 — Invalid Input
$
Input:
dayNumber = 8
›
Output:
Invalid
💡 Note:
Input 8 is outside the valid range of 1-7, so we return 'Invalid' to handle the error gracefully
Constraints
- Input will be an integer
- Valid range is 1 ≤ dayNumber ≤ 7
- Invalid inputs should return "Invalid"
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code