I want to get the variables values based on the parameter passed to the function. Is there any way to do this:
getDaysInCurrentMonth(type = 'all') {
const date = new Date(),
month = date.getMonth(),
year = date.getFullYear(),
days = new Date(year, month, 0).getDate();
if (type === 'all') return { date, month, year, days };
return [type];
}
For example, if I pass days in the getDaysInCurrentMonth('days')
, it should only return days. Is there any way to do this?