If Statements
In my 7 weeks of Web Programming 1, I got to learn about If Statements. If statements were the first "powerful" lines of code that we got to learn. After learning if statements, we ended up using them in just about every unit. The first example will allow the user to put in the score of their test, and the program will alert whether or not you passed. The second one will prompt the user enter their temperature in celsius, then the program will convert their number from celsius to fahrenheit. Once converted, the program will reccommend the user to either go hiking or to play some video games. Click the buttons below to see what each if statement will do!
const testGrade = parseInt(prompt("Enter your test grade."));
if(testGrade >= 70){
alert("You passed the test!")
}else{
alert("You failed the test!")
}
const celsius = parseInt(prompt("Enter the temperature in celsius."));
const fahrenheit = celsius * 9/5 + 32;
if(fahrenheit >= 65){
alert("It's time to go hiking!")
}else{
alert("Stay inside, maybe play some video games!")
}