課程的第一小章節終於結束了,其實對程式設計稍微有底的人,不太需要看課程也能做出來,但其實透過課程,可以發現一些本來不知道的小知識,也可以督促自己做點延伸閱讀~
其實是今天剛好比較忙,就拿小測驗擋一下吧~
題目 : 怕有版權問題稍微調整
/*
A and B are trying to compare their BMI.
1. Store A's and B's mass and height in variables
2. Calculate both their BMIs
3. Create a boolean variable containing information about whether A has a higher BMI than B.
4. Print a string to the console containing the variable from step 3.
*/
// ans
var mass_A, height_A, mass_B, height_B, BMI_A, BMI_B, isA_BMI_Higher;
mass_A = '100';
height_A = '1.9';
mass_B = '75';
height_B = '1.75';
BMI_A = Math.round(mass_A / Math.pow(height_A, 2));
BMI_B = Math.round(mass_B / Math.pow(height_B, 2));
console.log(BMI_A, BMI_B);
isA_BMI_Higher = BMI_A > BMI_B
console.log(isA_BMI_Higher);
console.log("Is A's BMI higher than B's? " + isA_BMI_Higher);
冷知識:十進位數指數
可透過 eN 替代數字尾隨的0, N = 的數量
console.log(2e5 + 10) // output = 200010
新手練功中, 歡迎指教、點評~
課程 : https://www.udemy.com/course/the-complete-javascript-course/