Question
For this program you need to take the following data and convert it into an array literal of Javascript object literals, where each object literal
For this program you need to take the following data and convert it into an array literal of Javascript object literals, where each object literal has three properties: a destination, a number of miles, and a number of gallons as shown below. You need to assign the array of objects to a variable, like trips,
Your array of objects cannot contain the mpg value. The value for miles per gallon must be calculated by the function called when the button is clicked.
For full credit:
Use Bootstrap to style the table.
The trip data needs to begin as an array literal of object literals, where each trip is an object with 3 properties.
The button must have an id property, and using getElementById('id') you must assign the function that displays the table to the button using an anonymous function in your JavaScript code.
Rather than use document.write(), you must use createElement() and appendChild(), similar to the example program in the DOM lecture notes.
Before being inserted into a table cell, the mpg must be calculated by the funciton and not be part of the object.
round the calculation to 1 decimal place
Trip Data Display Data Destination Chicago St. Louis Indianapolis Nashville Cincinnati Miles 329 284 191 132 Gallons 10.6 10.5 3.7 6.4 3.9 MPG 31.00 27.0 33.0 29.8 33.8Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started