Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need Help With Syntax Use your code editor to open the project11-01_txt.html and project11-01_txt.js files from the js11 project01 folder. Enter your name and the

Need Help With Syntax

Use your code editor to open the project11-01_txt.html and project11-01_txt.js files from the js11 project01 folder. Enter your name and the date in the comment section of each file and save them as project11-01.html and project11-01.js, respectively.

Go to the project11-01.html file in your code editor. Add a script element linked to the project11-01js file. Defer the loading of the script until after the page is loaded. Close the file, saving your changes.

Go to the project11-01.js file in your code editor. Within the anonymous function for the dateBox.onchange event handler, add the following:

Declare the dateStr variable and set it equal to the value of the dateBox element.

Use the fetch() method to make a request to the following url:

where dateStr is the value of the dateStr variable.

Add a then() method that takes a successful response and applies the json() method to the response object to parse the JSON text string.

Add a then() method that receives the JSON object and runs the showPicture() method with the JSON object as the parameter value.

Add a catch() method that displays the text of the rejected promise in the debugger console.

Create a function named showPicture() with a single parameter named json. Within the function create an if else structure that tests the following conditions:

If json.media_type equals video then change the inner HTML of the imageBox element to the following:

where url is the value of json.url, title is the value of json.title, and explanation is the value of json.explanation. (Hint: You might find it easier to specify this HTML code using a template literal.)

If json.media_type equals "image then change the inner HTML of the imageBox element to the following:

Otherwise, change the inner HTML of the imageBox element to the text string: Image not Available.

Save your changes to the file and then open project11-01.html in your web browser. Select a date from the Picture Date input box and verify that an image or video requested from the NASA APOD service for that date appears in the web page.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago