- Before proceeding - read this entire document
*thoroughly*! - Work on your own.
- Use only the JavaScript operations and commands we have described thus far in class.
- Download and unzip the starter archive.
- Write all your code in the file
`hw1.js`

. - Replace
`(YOUR NAME)`

with*your name*(without the parentheses) in the comment near the top of`hw1.js`

. - Open
`hw1-demo.html`

in your browser to experiment with my solution. - Open your
`hw1.html`

in your browser to test your solution. Remember to save your file in VS code and reload your`hw1.html`

in your browser as you continue to test your work. - Your written (i.e., non-programming) answers must be in the form of
`//`

comments. - Fill in all the areas of the supplied file marked by
`...`

. Remove the ellipses once you are finished with that part of the assignment. - Submit your work by uploading your
`hw1.js`

file via MySLC

- A very basic introduction to
*in-browser JavaScript*. - Only makes use of JavaScript features we have covered in class (and lab) so far: numbers, strings of text, variable assignments, simple arithmetic operations, string length and concatenation. Also,
`prompt`

and`alert`

dialog boxes for input and output. - The HTML file makes each of the five buttons trigger one of the six functions defined in your JavaScript code defined in your
`hw1.js`

file. - You are encouraged to try my solution.

Modify the function

`simpleAction`

so that it displays the message “This button works!” when triggered. You can test it by clicking on the first (left-most) button on your page. (Not on this page! On the page you view when you open your local copy of`hw1.html`

in your browser.)Complete the function

`secondsPerCentury`

so that it*computes*and displays (via the`alert`

function) the approximate number of seconds in a century. (By approximate, I mean assume a twenty-four day and ignore leap days.)**Include, as a comment, the resulting total number of seconds**.Write a function

`numberProblem`

that corresponds to the following prose description:Ask the user for a number. Ask the user for another number. Display the difference between the square of the sum of the two numbers and the sum of the squares of the two numbers.

For example, if the user enters 7 for the first number and 3 for the second number then it should display 42 as the answer since 100 is the square of the sum, and 58 is sum of the squares (49 + 9).

Use variables and assignments. For this particular problem, keep your arithmetic expressions very simple:

**no more than a single arithmetic operation per assignment statement**.An animation is a rapidly displayed sequence of images. (Old-fashioned cartoons would display hand-drawn images at a rate of anywhere from 4 to 12 images per second.) For this problem, we assume that an animation consists of 6000 distinct images and, given the length of the animation, we compute the animation frame rate (number of drawings displayed per second). Write a program that asks the user for the length of an animation in minutes (not seconds) and then computes and displays the rate. For example, if the user enters that an animation was 1 minute long, the program should display “Animation rate: 100 frames per second” as the result and if the length is 3 minutes (180 seconds) then it would display something less round like “Animation rate: 33.333333333333336 frames per second”.

(Optional) challenge: Round the rate down to a whole number. (For example, 3 minutes would lead to displayed rate of 33 frames per second90 seconds meaning 7 drawings were displayed.) To round down, use subtraction and the remainder (

`%`

) operator.Here is a simple arithmetic algorithm in JavaScript:

`let n = parseFloat(prompt('Enter a number: ')); let m = (5 * n) + 2; alert('Result: ' + m);`

You can try it here. Write the inverse function,

`inverse5n2`

to match this behavior: If the user enters 17 it displays the result as 3 (since seventeen minus two is fifteen and fifteen divided by five is three) and if the user enters 23 it returns 4 (not 4.2). The idea is to effectively perform “integer division” meaning have one integer divided by another, but throw away any remainder (i.e, round down). You can (and should) achieve this just by using some of the five arithmetic operations we have discussed (`+`

,`-`

,`*`

,`/`

,`%`

).Write a function

`concatLen`

that asks the user for two pieces of text and then displays, one dialog box at a time:- the length of the first string
- the length of the second string
- the concatenation of the two strings
- the length of that concatenation.

Example:

`Enter some text: hello Enter some more text: nwheels The first phrase has 5 characters The second phrase has 7 characters The concatenation of those phrases is: hellonwheels That has 12 characters`

In a

**comment**,*explain why*it makes sense for JavaScript to use`+`

for*both*the usual addition of two numbers*and*the concatenation of two strings.