-
-
Save achengfu/5fab09738abb4d14797535c94941abaa to your computer and use it in GitHub Desktop.
js:生日转换为星座
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
/* 生日转换为星座 | |
/* @param mon 月份 | |
/* @param day 日份(1-31) | |
/* @return string 对应日期生日的星座字符串 | |
**/ | |
function constellation(mon, day) { | |
var s = "魔羯水瓶双鱼牡羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯"; | |
var d = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22]; | |
var i = mon * 2 - (day < d[mon - 1] ? 2 : 0); | |
return s.substring(i, i + 2) + "座"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment