// 改之前
const arr = ['red', 'blue', 'green'];
const data = ['red', 'blue', 'green'];
// 改之後
const colors = ['red', 'blue', 'green'];
const colorList = ['red', 'blue', 'green'];
const colorData = ['red', 'blue', 'green'];
const colorArray = ['red', 'blue', 'green'];
// 改之前
const status = "disabled";
// 改之後
const buttonStatus = "disabled";
// 改之前
function updateInfo(info, data) {
...
}
// 改之後
function mergeInfoWithNewData(existingInfo, newData) {
...
}
// 改之前
function addProduct(name, price, quantity) {
const id = Date.now();
cart.push({
id: id,
productName: name,
price: price,
quantity: quantity
});
}
addProduct('Banana', 1, 1 );
// 改之後
function addProduct({ name, price, quantity }) {
const id = Date.now();
cart.push({
id: id,
productName: name,
price: price,
quantity: quantity
});
}
addProduct({ name: 'Banana', price: 1, quantity: 1 });
// 改之前
function printBMI(weight, height) {
// 計算 BMI
const bmi = (weight / ((height / 100) * (height / 100))).toFixed(2);
// 獲取 BMI 狀態
let state = '';
if (bmi < 18.5) {
state = 'overThin';
} else if (bmi < 24) {
state = 'normal';
} else if (bmi < 27) {
state = 'overWeight';
} else if (bmi < 30) {
state = 'mildFat';
} else if (bmi < 35) {
state = 'moderateFat';
} else if (bmi >= 35) {
state = 'severeFat';
}
if (!state) {
return '您的數值輸入錯誤,請重新輸入';
}
// 打印結果
console.log(`您的 BMI 數值為 ${bmi}, 體重狀態屬於 ${state}。`)
}
// 改之後
function calculateBmi(weight, height) {
return (weight / ((height / 100) * (height / 100))).toFixed(2);
}
function getBmiState(bmi) {
if (bmi < 18.5) {
return 'overThin';
} else if (bmi < 24) {
return 'normal';
} else if (bmi < 27) {
return 'overWeight';
} else if (bmi < 30) {
return 'mildFat';
} else if (bmi < 35) {
return 'moderateFat';
} else if (bmi >= 35) {
return 'severeFat';
} else {
return '';
}
}
function printBMI(weight, height) {
// 計算 BMI
const bmi = calculateBmi(weight, height);
// 獲取 BMI 狀態
const state = getBmiState(bmi);
if (!state) {
return '您的數值輸入錯誤,請重新輸入';
}
// 打印結果
console.log(`您的 BMI 數值為 ${bmi}, 體重狀態屬於 ${state}。`)
}
// 改之前
function getStatusMessage(status) {
if (status === 'success') {
return 'Operation was successful.';
} else if (status === 'error') {
return 'An error occurred.';
} else if (status === 'loading') {
return 'Loading...';
} else {
return 'Unknown status.';
}
}
// 改之後
const statusMessages = {
'success': 'Operation was successful.',
'error': 'An error occurred.',
'loading': 'Loading...',
'default': 'Unknown status.'
};
function getStatusMessage(status) {
return statusMessages[status] || statusMessages['default'];
}
source-over: 預設值,新的放在舊的上面source-atop: 新的在舊的上面,然後會把新的身上沒有跟舊的重疊的部分變不見source-in: 新的在舊的上面,然後只留下重疊的部分,其他都變不見(有點像打洞機打下去後得到的那個要丟掉的圓形)source-out: 新的在舊的上面,然後會把舊的部分+重疊的部分都拿掉,只留下沒重疊到的新的內容(有點像裁切的概念)destination-over: 新的在舊的下面destination-atop: 新的在舊的下面,然後會把舊的身上沒有跟新的重疊的部分變不見destination-in: 新的在舊的下面,然後只留下重疊的部分,其他都變不見(有點像打洞機打下去後得到的那個要丟掉的圓形)destination-out: 新的在舊的下面,然後會把新的部分+重疊的部分都拿掉,只留下沒重疊到的舊的內容(有點像裁切的概念)lighter: 新的在舊的上面,重疊部分高亮copy: 直接把舊的變不見,只留下新的xor: 新的在舊的上面,重疊的部分變不見(有點像打洞機打下去後得到的那張有洞的紙)
Oct 31, 2024通過 slots 建立 tab 功能
Apr 4, 2024假設我們從後端獲取到一篇部落格的 html 要渲染到畫面上但裡面有很多連結,且有些是連到網站其他分頁點擊連結後會發現 Network 發送了許多不必要的請求,將網站整個 reload 了
Apr 4, 2024進入Flutter 官方網站,點擊右上角『Get started』
Jan 26, 2024or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up