Client-Side Web Development - Graded Assignment #3

  1. Use VS Code to open the HTML file index.html in which you completed the first two assignments.
  2. Create an empty Javascript file called main.js in the same folder.
  3. Using a script element in the HTML fila, include the Javascript file just above the body close tag.
  4. In the Javascript file, define a function that takes two parameters, start and end and returns a random whole number between start and end, inclusive of start and end (which means that if start equals 2 and end equals 7, then the random number should be from the set {2, 3, 4, 5, 6, 7}). Give the function a suitable name, based on what it does. To generate the random number, you can use the following expression:
    
    Math.floor(Math.random() * count) + start
    		    
    This expression generates a random whole number in the range that starts with start and has count members. For example if start equals 3 and and count equals 4, then the expression will generate a number from the set {3, 4, 5, 6}.
  5. In the Javascript file, write some code that outputs the following string to the console when the HTML page is loaded in the browser:
    
    "Client-Side Web Development graded assignment submitted by <your name>..."
    		    
    For example:
    
    "Client-Side Web Development graded assignment submitted by Bob Cratchit..."
    		    
  6. In the Javascript file, write some code that writes the following to the console:
    
    "and the lucky number is <a number between 1 and 10 generated by the function written in step 4>"
    		    
    For example, if the random number happens to be 9, the following should appear on the console:
    
    "and the lucky number is 9"
    		    
  7. Make sure to test your solution with the use of the developer tools in the browser before submitting it.

 

For information on submission deadline and grading of this assignment see the the Schedule and Notes page, below the table.