# 任務挑戰三:ChatGPT AI 程式題詠唱訓練 (Lili)
## 1. 請用 chatGPT 解答10 道 if+function 題目 (1,3,5,7,9)
### **題目一:多重條件**
一週有七天,請製作一個函式可輸入不同的星期日數,並回傳當天的心情小語,如下例:
詠唱語句
use switch function put parameter which is week day number and out put string about that day feeling
```jsx
function weekdayFeeling(dayNum) {
switch(dayNum) {
case 1:
return "Ugh, it's Monday...";
case 2:
return "Getting into the swing of things.";
case 3:
return "Hump day! Halfway there!";
case 4:
return "Almost Friday, keep pushing!";
case 5:
return "TGIF! Let's finish strong!";
case 6:
return "Weekend vibes, time to relax!";
case 7:
return "Chill out, it's still the weekend!";
default:
return "Invalid input. Please enter a valid day number between 1 and 7.";
}
}
console.log(weekdayFeeling(1)); // Output: Ugh, it's Monday...
console.log(weekdayFeeling(6)); // Output: Weekend vibes, time to relax!
console.log(weekdayFeeling(8)); // Output: Invalid input. Please enter a valid day number between 1 and 7.
```
### **題目三:發燒檢測**
人的中心體溫通常會自動調節在 37 ℃ 左右,只要 ≥ 38度就代表可能發燒了!請製作一個探測人體溫度是否發燒的函式。
詠唱語句
make a function to return if one human temperature more than 37 ℃ have fever is true
```jsx
function hasFever(temperature) {
return temperature > 37;
}
console.log(hasFever(36.5)); // Output: false
console.log(hasFever(38)); // Output: true
console.log(hasFever(37)); // Output: false
```
### **題目五:餵食青蛙**
請幫遊戲內的青蛙角色設計被餵食飼料時的反應,輸入不同種類單位大小的飼料,讓青蛙做出相對應的回饋,如下範例:
- 飼料太小(<=5) 回傳 “嘓!”
- 飼料太大(>=50) 回傳 “嘔”
- 如果以上都不是,回傳 “…”
詠唱語句
use function return frog being fed reaction , if food number small and equal 5, frog reaction is "嘓!", if food number big and equal 50, frog reaction is "嘔",and other food number frog reaction is ".....”
```jsx
function feedFrog(foodNumber) {
if (foodNumber <= 5) {
return "嘓!"; // "嘓!" means "Yuck!"
} else if (foodNumber >= 50) {
return "嘔"; // "嘔" means "Barf!"
} else {
return "....."; // "....." represents a neutral or indifferent reaction
}
}
console.log(feedFrog(3)); // Output: 嘓!
console.log(feedFrog(25)); // Output: .....
console.log(feedFrog(75)); // Output: 嘔
```
### **題目七:BMI 計算**
BMI 稱為身體質量指數(Body Mass Index,縮寫為BMI),是目前美國疾病管制局及世界衛生組織所認可,利用身高為基礎來測量體重是否符合標準。請套用以下公式製作一個 BMI 計算函式。
詠唱語句
use one function return one person's BMI value and waistline whether out of stander, the parameter include gender and height(cm) and weight(kg) and waistline(cm), BMI value is small than 18.5 return "體重過輕", BMI value is equal 18.5 and between 18.5 to 24 return "正常範圍",BMI value equal 24 and between 24 to 27 return "過重”,BMI value equal 27 and between 27 to 30 return "輕度肥胖",BMI value equal 30 and between 30 to 35 return "中度肥胖",BMI value equal 35 and more than 35 return "重度肥胖",and gender is men, his waistline is equal and more than 90cm , return "腰圍過大", other is "腰圍正常", if gender is female , her waistline is equal and more than 80cm , return "腰圍過大", other is "腰圍正常".
```jsx
function calculateBMI(gender, height, weight, waistline) {
// Convert height from cm to meters
height = height / 100;
// Calculate BMI value
var bmi = weight / (height * height);
// Determine waistline status based on gender and waistline value
var waistlineStatus = "";
if (gender === "male") {
if (waistline >= 90) {
waistlineStatus = "腰圍過大";
} else {
waistlineStatus = "腰圍正常";
}
} else if (gender === "female") {
if (waistline >= 80) {
waistlineStatus = "腰圍過大";
} else {
waistlineStatus = "腰圍正常";
}
}
// Determine BMI status based on BMI value
var bmiStatus = "";
if (bmi < 18.5) {
bmiStatus = "體重過輕";
} else if (bmi >= 18.5 && bmi < 24) {
bmiStatus = "正常範圍";
} else if (bmi >= 24 && bmi < 27) {
bmiStatus = "過重";
} else if (bmi >= 27 && bmi < 30) {
bmiStatus = "輕度肥胖";
} else if (bmi >= 30 && bmi < 35) {
bmiStatus = "中度肥胖";
} else if (bmi >= 35) {
bmiStatus = "重度肥胖";
}
// Return the BMI value and waistline status as an object
return { bmi: bmi.toFixed(1), bmiStatus: bmiStatus, waistlineStatus: waistlineStatus };
}
console.log(calculateBMI("male", 180, 75, 80)); // Output: { bmi: "23.1", bmiStatus: "正常範圍", waistlineStatus: "腰圍正常" }
console.log(calculateBMI("female", 160, 60, 85)); // Output: { bmi: "23.4", bmiStatus: "正常範圍", waistlineStatus: "腰圍過大" }
console.log(calculateBMI("male", 170, 85, 95)); // Output: { bmi: "29.4", bmiStatus: "中度肥胖", waistlineStatus: "腰圍過大" }
```
### **題目九:FizzBuzz**
FizzBuzz 是一個簡單的小遊戲,給定一串從 1 到 100 的數字:
- 如果是 3 的倍數,就印出 “Fizz”
- 如果是 5 的倍數,就印出 “Buzz”
- 如果同時是 3 和 5 的倍數,就印出 “FizzBuzz”
- 將結果回傳為一個陣列。
詠唱語句
use JavaScript function count 1 to 100, if number multiple of 3 print "Fizz", if number multiple of 5 print "Buzz",if number is equal to multiple 3 and multiple 5 print "FizzBuzz", and console log this result use array
```jsx
function fizzbuzz() {
let result = [];
for (let i = 1; i <= 100; i++) {
if (i % 3 === 0 && i % 5 === 0) {
result.push("FizzBuzz");
} else if (i % 3 === 0) {
result.push("Fizz");
} else if (i % 5 === 0) {
result.push("Buzz");
} else {
result.push(i.toString());
}
}
console.log(result);
}
```
## 2. 請用 chatGPT 詠唱以下 Bootstrap 5 文件的募資網站中,詠唱下圖範圍版型,並分享自己的詠唱語法與 Codepen,來看哪組的小組詠唱能力最接近。
Input:
```
請幫我做一個商品頁面,頁面背景是#F8F9FA,有label是魔法科技,title是拍出會動的照片 | LivePhotos拍立得,title的下方分兩個區塊,左邊區塊請幫我放上圖片,image 的src是https://hexschool.github.io/boootstrap5WebLayout/assets/produt_image.jpg,另外右邊的區塊最上面有span內容是%22目標$600,000%22,span下方有title內容是%22目標$280,047%22,title下方還有range bar,bar裡面的顏色是#FFDF65 來顯示"41%",range bar 下方有兩個div,左邊的div裏面上方放label內容是"贊助人數",下方放h5內容是"1374人",右邊的div裡面放label內容是"募資倒數",下方放h5內容是"27天",下方擺放4個icon 並排,icon的src是https://hexschool.github.io/boootstrap5WebLayout/assets/icon_good01.svg,
https://hexschool.github.io/boootstrap5WebLayout/assets/icon_good02.svg,
https://hexschool.github.io/boootstrap5WebLayout/assets/icon_good03.svg,
https://hexschool.github.io/boootstrap5WebLayout/assets/icon_good04.svg,
在4個icon的下方有一個div,背景是白色,左邊有border是#FFDF65。
div裡面有兩行string並排,一行string是專案募集中!",另一行string是"在 2021/06/14 23:59 募資結束前,您都可以贊助我們!"。
下方有一個button,圓角26px,寬452px,其button的顏色是#FFDF65,button的label是"贊助專案"。
這個button下方還有兩個button並排,兩個button的background-color都是白色,圓角26px,文字顏色是#858377。左邊的button裡面內含一個icon,icon是font-awesome的heart,button寬度是269px,label是追蹤專案,另外右邊的button裡面也內含一個icon,icon是font-awesome的share-alt,label是分享,請用bootstrap撰寫html頁面。
```