CS 315 Homework 4: Javascript

Assigned: 4 March 2020   Due: 27 March 2020

This homework problem is to be done individually, not in pairs or other groups. Your completed assignment should be submitted using the Assignment Submission Page.

Your solution should use valid HTML5 syntax. You should validate your pages using the W3 HTML validator and the CSS validator as described in class. Your Javascript code is NOT allowed to use the Prototype Framework for this assignment. Please just use "vanilla" Javascript as discussed in class. Your Javascript should be unobtrusive, as defined in class.

Write a Javascript program that asks the user for two strings.

If either input is invalid, your program should reject it (specifying what is invalid) and quit.

Given two valid inputs, your program should print out the time of day that results from adding the time difference to the particular time. It should print that time in the standard format described above for the first input. It should always include AM or PM. It should always have two digits for the minutes and one or two digits for the hours. If the new time is in the next day, it should include + 1 day in the output time.

  • Javascript has an extensive Date/Time package which you are not to use for this assignment. You should use the code in: jsexample20.html and jsexample20.js or something like it to unobtrusively read in the times from the user and present the results.