Has the kettle boiled? If so, then pour water into cup; otherwise, continue to wait.
| Symbol |
Purpose |
|---|---|
== |
is equal to |
< |
is less than |
> |
is greater than |
<= |
is less than or equal to |
>= |
is greater than or equal to |
!= |
is not equal to |
var num = 10; //num equals 10if (num == 10); //if num is equal to 10 "If the room temperature is more than 80 degrees Fahrenheit, then I'll turn the air conditioning on."if (roomTemperature > 80) {
roomTemperature = roomTemperature – 10;
} if (condition) {
some code
some code
}if(roomTemperature > 80)
roomTemperature = roomTemperature – 10; var userChoice = window.confirm("Choose OK or
Cancel");
if (userChoice == true) {
document.write("OK");
}
if (userChoice == false) {
document.write(“Cancel”);
}<script type="text/javascript">
var degFahren = prompt("Enter the degrees Fahrenheit",32);
var degCent;
degCent = 5/9 * (degFahren - 32);
document.write(degFahren + "\xB0 Fahrenheit is " + degCent + "\xB0 centigrade<br>");
if (degCent < 0) {
document.write("That's below the freezing point of water"); }
if (degCent == 100)
document.write("That's the boiling point of water");
</script> if (degCent < 0) {
document.write("That's below the freezing point of water");
}
if (degCent == 100)
document.write("That's the boiling point of water"); | Operator |
Symbol |
|---|---|
AND |
&& |
OR |
|| |
NOT |
! |
"If I feel cold and I have a coat, then I'll put my coat on."if (isCold && haveCoat){
putOnCoat();
}ch3_examp2.htm "If it is raining or if it is snowing, then I'll take an umbrella."if (isRaining || isSnowing){
takeUmbrella();
}ch3_examp2.htm "If I'm not hot, then I'll eat soup."if (!hot){
eatSoup();
}ch3_examp2.htm "If it is raining, I will take an umbrella, otherwise I will take a sun hat"if (isRaining){
takeUmbrella();
}
else { takeSunHat(); }"If it is raining, I will take an umbrella, otherwise if the sun is shining, I will take a sun hat"if (isRaining){
takeUmbrella();
}
else if (isSunShining){
takeSunHat();
}var myName ="paul";
if (myName == "Paul")
{
alert("myName is Paul");
}var myName = "Joe";
switch (myName){
case "Paul":
//some code
break;
case "John":
//some code
break;
default:
//some code
break;
}switch (myName)case "John":var secretNumber = prompt("Pick a number between 1 and 5:", "");
secretNumber = parseInt(secretNumber);
switch (secretNumber)
{
case 1:
document.write("Too low!");
break;
case 2:
document.write("Too low!");
break;
....
default:
document.write("You did not enter a number between 1 and 5.");
break;
}