Find greatest among 3 numbers – requirements
The requirement is to find greatest among 3 numbers. You can either let the users enter 3 numbers using a prompt box and store it in a variable or use 3 inputs text field to accept number or define 3 variables and store values in it. If you are comfortable working with arrays, you can use an array of 3 numbers for comparision.
Find greatest among 3 numbers – hints
- Compare the first two numbers using a if/else statement and save value of the greater number in a temporary variable named “larger’.
- Now compare the value of third number with the value stored in the ‘larger’ variable using the if/else statement.
- Display the greatest number using an alert box or show it in the body of the page using document.write
Need help? here is the the tutorial