-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
64 lines (51 loc) · 2.03 KB
/
app.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//Return full nam e
var prompt = require('sync-prompt').prompt;
var firstName = prompt('What is your first name? ');
var lastName = prompt('What is your last name? ');
console.log('You full name is', firstName, lastName)
// //Return favorite color
var color = prompt('What is your favorite color? ');
console.log('Your favorite color is', color);
// get dog age and convery to human age
var age = prompt('What is your dog\'s age? ');
// console.log(typeof age)
age = parseInt(age);
// console.log(typeof age)
dogage = age*7
console.log('Your dog is ' + age + ' in human years.');
console.log( 'That\'s ' + dogage + ' in dog years!')
//Get user age
var userAge = prompt('What is your age?');
userAge = parseInt(userAge);
//Drinking age
if(userAge >= 21) {
console.log('You are 21 or older, go get wasted!')
}else{console.log('You are too young to drink. Too bad!')
}
temperature conversion
var scale = prompt('Do you want to convert from F or C? ')
var tempType = scale.ToUpperCase();
if(tempType === 'F'){
var temp = prompt('What is your temp in F? ')
temp = parseInt(temp)
console.log( temp + ' degrees F is ' + (((temp-32)*5)/9) + ' degrees C')
}else if(tempType === 'C'){
var temp = prompt('What is your temp in C? ')
temp = parseInt(temp)
console.log( temp + ' degrees C is ' + (((temp*9 )/5)+32) + ' degrees F')
}else{console.log(tempType + ' is not a valid scale. Next time please enter F or C')
}
console.log('Welcome to the BMI calculator')
var weightLB
var heightFT
var heightIN
weightLb = prompt('Please enter your weight in lbs: ')
heightFT = prompt('Please enter your height, rounded down to the nearest foot: ')
heightIN = prompt('How many inches above ' + heightFT + ' feet are you? ')
heightFT = parseInt(heightFT)
heightIN = parseInt(heightIN)
var heightTotal = (heightFT * 12)+heightIN
console.log('You are', heightTotal, 'inches tall and you weigh', weightLb, 'pounds')
var BMI = ((weightLb * 703)/Math.pow(heightTotal,2))
BMI = parseFloat(BMI).toFixed(1);
console.log('This means you have a BMI of ' + BMI)