Question: 1. Create an external JavaScript file named assn2.js to do the following: a. Add a function greeting(). The function will take a name argument with

1. Create an external JavaScript file named assn2.js to do the following:

a. Add a function greeting(). The function will take a name argument with a default value "Guest", though the default argument may not take any effect in this assignment The function will display a welcome message at the beginning of the main content area using a separate paragraph. The original html content will be displayed after the greeting message. HINT: You may use getElementByld() or querySelector() method to get hold of the element, then use innerHTML property to change its content.

b. Add a function, printFooter, after the greeting() function This function will replace the document footer content with "Today is " followed by the date that the user visits your site in the forma of mm/dd/yyyy.

c. Assume you have an images folder on the site that contains 5 images named photo1.jpg, photo2.jpg, etc. You may use png images if you like. Create a function named randomImage() that will 1) produce a random integer between 1 and 5 inclusive; 2) use the integer to make the image name string in the form of images\filename.jpg so that it can be used for the image's sre attribute. The function will return the image name string.

d At the end of assn2.js file, ask for the user's name, then call the greeting function and passing in the user name as the argument. Afterward, call printFooter function. Can you move the code of this step to the beginning of the js file to achieve the same result? explain vour answer

2. Make sure you have an image element in the header section and let the image respond to the click event so that when the image is clicked on, it will replace the current image with the image selected by the randomlmage function

3. Link the assn2.js file at the bottom but above the body closing tag of the html page Test the page with a browser You should see a similar result as displayed below. Can you link the js file in the head of the html file to get the same result? Why or why not?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!