多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# getConstellationByBirthday(根据出生判断星座) ## 一:示例 ![mark](http://qiniu.newthink.cc/blog/20170220/142043849.png) ## 二:相关代码 ``` /** * [getConstellationByBirthday 根据出生年月判断属于哪一个星座] * @author [hongwei] * @param {[string]} strBirthday [出生日期] * @return {[string]} [12星座中的一个] * @example getConstellationByBirthday('1983-11-17'); 结果是 :天蝎座 * @link http://www.kancloud.cn/hongweizhiyuan/apicloud_function/274920 */ function getConstellationByBirthday(strBirthday) { var value; var strBirthdayArr=strBirthday.split("-"); var birthMonth = strBirthdayArr[1]; var birthDay = strBirthdayArr[2]; if (birthMonth == 1 && birthDay >=20 || birthMonth == 2 && birthDay <=18) {value = "水瓶座";} if (birthMonth == 1 && birthDay > 31) {value = "Huh?";} if (birthMonth == 2 && birthDay >=19 || birthMonth == 3 && birthDay <=20) {value = "双鱼座";} if (birthMonth == 2 && birthDay > 29) {value = "Say what?";} if (birthMonth == 3 && birthDay >=21 || birthMonth == 4 && birthDay <=19) {value = "白羊座";} if (birthMonth == 3 && birthDay > 31) {value = "OK. Whatever.";} if (birthMonth == 4 && birthDay >=20 || birthMonth == 5 && birthDay <=20) {value = "金牛座";} if (birthMonth == 4 && birthDay > 30) {value = "I'm soooo sorry!";} if (birthMonth == 5 && birthDay >=21 || birthMonth == 6 && birthDay <=21) {value = "双子座";} if (birthMonth == 5 && birthDay > 31) {value = "Umm ... no.";} if (birthMonth == 6 && birthDay >=22 || birthMonth == 7 && birthDay <=22) {value = "巨蟹座";} if (birthMonth == 6 && birthDay > 30) {value = "Sorry.";} if (birthMonth == 7 && birthDay >=23 || birthMonth == 8 && birthDay <=22) {value = "狮子座";} if (birthMonth == 7 && birthDay > 31) {value = "Excuse me?";} if (birthMonth == 8 && birthDay >=23 || birthMonth == 9 && birthDay <=22) {value = "室女座";} if (birthMonth == 8 && birthDay > 31) {value = "Yeah. Right.";} if (birthMonth == 9 && birthDay >=23 || birthMonth == 10 && birthDay <=22) {value = "天秤座";} if (birthMonth == 9 && birthDay > 30) {value = "Try Again.";} if (birthMonth == 10 && birthDay >=23 || birthMonth == 11 && birthDay <=21) {value = "天蝎座";} if (birthMonth == 10 && birthDay > 31) {value = "Forget it!";} if (birthMonth == 11 && birthDay >=22 || birthMonth == 12 && birthDay <=21) {value = "人马座";} if (birthMonth == 11 && birthDay > 30) {value = "Invalid Date";} if (birthMonth == 12 && birthDay >=22 || birthMonth == 1 && birthDay <=19) {value = "摩羯座";} if (birthMonth == 12 && birthDay > 31) {value = "No way!";} return value; } ```