-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
50 lines (46 loc) · 1.31 KB
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
import inquirer from "inquirer";
async function bmicalc (){
const weightandHeight = await inquirer.prompt([
{
type: "number",
name: "weight",
message: "Please enter your weight in KG?"
},
{
type: "number",
name: "height",
message: "Please enter your height in feet?",
}
]);
const{weight,height} = weightandHeight;
let heightInMeter = height * 0.3048;
let bmi = weight/(heightInMeter*heightInMeter);
console.log(`Your BMI is ${bmi}.`);
if(bmi < 18.5){
console.log(`You are week!`)
}else if(bmi >= 18.5 && bmi < 25){
console.log(`You are healthy!`)
}else if(bmi >= 25.0 && bmi < 30){
console.log(`You are overweight!`)
}else if(bmi >= 30.0 && bmi < 35){
console.log(`You are obese class 01!`)
}else if(bmi >= 35 && bmi < 40){
console.log(`You are obese class 02!`)
}else if(bmi >= 40){
console.log(`You are obese class 03 "severe" obesity!`)
}
}
async function startAgain() {
do {
await bmicalc();
var restart = await inquirer
.prompt({
type: "list",
name: "recoco",
message: "Do you want to continue? Select 'Yes' to restart , 'No' to close:",
choices: ['Yes', 'No']
})
}while(restart.recoco === 'Yes')
}
startAgain();