This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dayName(day) { | |
// Load the day names from a file | |
const dayNames = require('./weekday.json'); | |
// Were there seven names in the array? | |
if (dayNames.length != 7) | |
throw 'Error in weekday.json'; | |
// Is day value between 1-7? | |
if (day < 1 || day > 7) | |
throw 'Invalid day number'; | |
// Array start with 0, Mon -> 1 | |
return dayNames[day-1]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment