Page 160 - Computer Software Application TP - Volume 1
P. 160
COMPUTER SOFTWARE APPLICATION - CITS
3 Save the program as a .html file
4 Open the html file with a web browser
5 Verify the output.
1 Create a JavaScript object named book with properties title, author, and pages. Initialize the title property with
“The Great Gatsby”, author with “F. Scott Fitzgerald”, and pages with 180.
2 Define a JavaScript class named Circle with properties radius and calculateArea method that calculates the
area of the circle. Create an instance of the Circle class with a radius of 7 and calculate its area.
3 Create a constructor function named Car that initializes the properties make, model, and year. Create an
instance of the Car object with the make “Ford”, model “Mustang”, and year 2022.
4 Develop a JavaScript program that dynamically adds new elements (e.g., paragraphs, images) to a webpage
when a button is clicked. Use DOM manipulation
5 Create a JavaScript program that generates a random number between 1 and 100. Display the generated
number on the webpage inside a <div> element using the innerHTML property.
6 Develop a JavaScript program that calculates the factorial of a given number entered by the user. Display the
result on the webpage using the innerHTML property.
145
CITS : IT & ITES - Computer Software Application - Exercise 40 CITS : IT & ITES - Computer Software Application - Exercise 40