Last active
April 19, 2017 06:42
-
-
Save Ding-Fan/263374c5ab74dba3d23c5723e71024a6 to your computer and use it in GitHub Desktop.
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
// 作业1: 摄氏度转换为华氏度 | |
function cToF (celsius) { | |
return celsius + ' 摄氏度等于 ' + (celsius * 33.8).toFixed(2) + ' 华氏度' | |
} | |
console.log(cToF(24)) | |
// 作业2:交换两个变量的值 | |
function swap(alice, bob) { | |
var table | |
table = alice | |
alice = bob | |
bob = table | |
return '现在 alice 有 ' + alice + ' 个,bob 有 ' + bob + ' 个' | |
} | |
console.log(swap(5, 8)) | |
// 作业3:JS作为计算器 | |
function lifeCycle () { | |
var lament = '假设\n' + | |
'一个普通人类一个小时能写 200 行代码\n' + | |
'一个项目有 100000 行代码\n' + | |
'那么,一个普通人类写完一个项目需要 ' + (100000 / 200) + ' 小时\n' + | |
'一天工作 8 小时,一个月工作 21 天\n' + | |
'完成这个项目需要 ' + Math.ceil(100000 / 200 / 8 / 21) + ' 个月\n' + | |
'一个项目能挣 50000 人民币\n' + | |
'上海二手房 4 月均价 54520 元/㎡\n' + | |
'……\n' + | |
'……\n' + | |
'……\n' | |
return lament | |
} | |
console.log(lifeCycle()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment