//根据年月日获取星座
function getZodiacSign(dateString){
// 用法:const dateStr ='2024-01-11';
// const zodiacSign = getZodiacSign(dateStr);
const date= new Date(dateString);
const month = date.getMonth() + 1;
const day = date.getDate();if((month ===1&& day >=20)||(month ===2&& day <=18)){return'水瓶座';}elseif((month ===2&& day >=19)||(month ===3&& day <=20)){return'双鱼座';}elseif((month ===3&& day >=21)||(month ===4&& day <=19)){return'白羊座';}elseif((month ===4&& day >=20)||(month ===5&& day <=20)){return'金牛座';}elseif((month ===5&& day >=21)||(month ===6&& day <=21)){return'双子座';}elseif((month ===6&& day >=22)||(month ===7&& day <=22)){return'巨蟹座';}elseif((month ===7&& day >=23)||(month ===8&& day <=22)){return'狮子座';}elseif((month ===8&& day >=23)||(month ===9&& day <=22)){return'处女座';}elseif((month ===9&& day >=23)||(month ===10&& day <=22)){return'天秤座';}elseif((month ===10&& day >=23)||(month ===11&& day <=21)){return'天蝎座';}elseif((month ===11&& day >=22)||(month ===12&& day <=21)){return'射手座';}else{return'摩羯座';}}
const dateStr ='2024-01-11';
const zodiacSign = getZodiacSign(dateStr);
console.log('星座', zodiacSign);