Create an object that contains the 2 random numbers generated from JavaScript random function. The object should also contain a function that finds the bigger one of the two numbers. Display the 2 random numbers in the attached html file, then display the larger of the two with appropriate label. Here is my HTML code
<!DOCTYPE html>
<html>
<head>
<title>midterm exam</title>
<link rel="stylesheet" href="css/q1.css"
/>
</head>
<body>
<section id="page">
<h1>Question
1</h1>
<section
id="whitespace"></section>
</section>
<script
src="js/q1.js"></script>
</body>
</html>
If you have any problem with the code feel free to comment.
JavaScript Program
var numObj = {
//generating radome number between 0-100
number1 : Math.floor(Math.random()*100),
number2 : Math.floor(Math.random()*100),
//finding the bigger number
biggerOne(){
if(this.number1 > this.number2)
return this.number1;
else
return this.number2;
}
};
//printing the output
document.write('Number 1: '+numObj.number1+'<br>');
document.write('Number 2: '+numObj.number2+'<br>');
document.write('Bigger Number: '+numObj.biggerOne());
Output

Create an object that contains the 2 random numbers generated from JavaScript random function. The object...