1) 조건문이란?
if (조건식){
실행할코드
}
2) 음주가능 나이 판별기
const age = parseInt(prompt('how old are you?'));
console.log(isNaN(age));
if (isNaN(age) || age < 0) {
console.log('Please write a real positive number');
} else if (age < 18) {
console.log('You are too young');
} else if (age >= 18 && age <= 50) {
console.log('You can drink');
} else if (age > 50 && age <= 80) {
console.log('You should drink little');
} else if (age>80) {
console.log('You can do whatever you want ');
}
3) falsy
4) parseInt(), isNaN()
parseInt(1)// -> 1
parseInt('1')// -> 1
parseInt(1.9)// -> 1
parseInt('1.9')// -> 1
parseInt('-1')// -> -1
parseInt('a')// -> NaN