Edit M150_TMA05_2008J_Q1_task01.html replacing the existingThe code I have so far is below but I don't think its right please help as I need to complete this part to move onto the next.
JavaScript with the function,
getRoundedRandomNumber(aNumber). This function should
return whole numbers between 0 and aNumber, using
Math.round() as outlined above.
Write a comment to document what this function does, using an
extended comment (that is, one between /* and */). Also
provide appropriate single-line comments (the ones starting
with //) in the code, describing how it works. Paste a copy of
the getRoundedRandomNumber() function into your Solution
Document.
Also remove the line of code and associated comment you wrote
for part (ii).
2
Read the ONCLICK event handler for the file’s HTML form to
understand how getRoundedRandomNumber() is invoked and
how the returned number is displayed.
Expand|Select|Wrap|Line Numbers
- <HTML>
- <HEAD>
- <TITLE>M150 TMA 5 : Programming : Task 1 - Testing Math.random()</TITLE>
- <SCRIPT language = "JavaScript">
- //generate a random number greater than or equal to 0.0 and less than 50.0
- //rounded to a whole number
- //and display it in an alert dialogue
- var getRoundedRandomNumber = Math.round(Math.random()*49);
- window.alert("Random number returned is: " + getRoundedRandomNumber);
- //generate a random number and round down
- var getRandomNumber = Math.floor(Math.random()*49)
- </SCRIPT>
- </HEAD>
- <BODY>
- <STRONG>A test of the random number functions <BR></STRONG>
- <FORM NAME = "randomForm">
- <INPUT TYPE = "button" NAME = "randomButton" VALUE ="Display Random Number!"
- ONCLICK = "window.alert(getRandomNumber);">
- </FORM>
- </BODY>
- </HTML>