Page 215 - Web Applications (803) Class 12
P. 215
greeting();
</script>
The best use of anonymous functions is that they can be supplied as arguments to other functions.
Experiential Learning
Lab Assignment ‘n Activity
Complete the following activities and tick on the circle.
Accept a string from the user and display “Hello <Name>” in an alertbox.
Accept a number from the user and display its square and cube on the webpage.
Accept 5 numbers from the user and display the largest number in an alertbox.
3.13 MATH OBJECT
We have seen that the String object offers formatting and string manipulation methods and properties.
Similarly, numerous mathematical operations are supported by the Math object, including abs(), log(), pow(),
random(), round(), and sqrt(). Let us understand each.
Method Name Description Example
round() a number is rounded to the document.write(Math.round(3.68));
nearest integer document.write(“,” +Math.round(5.30));
document.write(“,”+Math.round(-8.78));
Output:
4,5,-9
random() returns an arbitrary value document.write(Math.random());
between 0 (inclusive) and 1 Output:
(exclusive)
0.5492547873757196
max() returns the largest number document.write(Math.max(-15, -20));
document.write(“<br>”+Math.max(150,
130, 120, 138));
Output:
-15
150
min() Returns the smallest number document.write(Math.min(-15, -10));
document.write(“<br>”+Math.min(155,
132, 123, 13));
Output:
-15
13
Web Scripting—JavaScript 213

