Page 98 - PortGPT_V2.1_C8_Flipbook
P. 98
document.write("Second number is greater then first number");
}
2. var num = 3.4;
if (num > 0)
{
document.write("Positive number");
}
else
{
document.write("Negative number");
}
Let's exPLore
Surf the Internet and find more programs of looping in JavaScript.
tech Practice
Write a program to:
1. check whether the year input by the user is a leap year or not (a year is a Leap year, if the
year is a multiple of 4 and isn’t a multiple of 100 or if the year is a multiple of 400).
2. calculate the area of square or circle according to the given input by the user. If the input
is 1, then calculate area of square, else find the area of a circle. Ask the user to input the
values for square or circle, based on the input.
3. find whether the given character is a vowel or not.
4. check if the input number is positive or negative.
5. input three numbers from the user, then print ‘You Won’ if the sum of input numbers is
greater than 1000.
For The Teacher
• Discuss all the topics covered in this chapter with the students.
• Tell the students, how to use indentation to define the body of the conditional statement.
• Discuss the concept of control structures in JavaScript with the students.
96 Premium Edition-VIII

