|
|
|
|
|
by Zyst
2981 days ago
|
|
In fairness I think that would look a bit more like this: const getDate = (date) => {
switch (date) {
case 1:
return 'mon'
case 2:
return 'tues'
default:
return 'wed'
}
}
let date = getDate(1)
Which is, of course, still less terse. What I normally use when I have cases like this is an object-as-a-map. IE: const dates = {
1: 'mon',
2: 'tues'
}
let day = dates[3] || 'wed';
|
|