My previous post on conditionals described a statement that tests whether the two properties are true or false. TRUE or FALSE is returned and printed out.
In this case, we want to display a different answer based on the conditional.
At the bottom of the script you can see the nested if/else if/else statement. If the condition being tested is true, the code within the block will be executed, otherwise, it'll keep going down the list until it finds the correct condition.
As soon as the first match is made there is no reason to test any further arguments.
In this simple example, we're asking the user to enter his/her height and weight to test for BMI. The weight and height are converted into kilograms and meters respectively and the BMI is calculated.
In this case, we want to display a different answer based on the conditional.
At the bottom of the script you can see the nested if/else if/else statement. If the condition being tested is true, the code within the block will be executed, otherwise, it'll keep going down the list until it finds the correct condition.
As soon as the first match is made there is no reason to test any further arguments.
In this simple example, we're asking the user to enter his/her height and weight to test for BMI. The weight and height are converted into kilograms and meters respectively and the BMI is calculated.
Comments
Post a Comment