Javascript/Javascript
[์๋ฐ์คํฌ๋ฆฝํธ ์์ ] ๋งค๊ฐ๋ณ์ ์์ ๋ฐ๋ฅธ Function return ์ ์ด
Rainbow๐Coder
2022. 3. 15. 22:33
728x90
<์์ >
function cal(year, month, date) {
let todayYear = year;
let todayMonth = month;
let todayDate = date;
if (todayDate) {
return `${year} / ${month} / ${date}`;
} else if (todayMonth) {
return `${year}๋
${month}์`;
} else todayYear;
{
return `์ด์๋ํต ${year}๋
`;
}
}
console.log(cal("2022", "3", "15"));
console.log(cal(2022, 3));
console.log(cal(2022));
<์ถ๋ ฅ ๊ฒฐ๊ณผ>
2022 / 3 / 15
2022๋
3์
์ด์๋ํต 2022๋
728x90