Write a Javascript program with explaination  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. You should concatenate the table elements as shown in the examples in the notes for JavaScript objects. Before being inserted into a table cell, the mpg must be calculated and not be part of the data objects. round the calculation to 1 decimal place

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a Javascript program with explaination 

  • 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.
  • You should concatenate the table elements as shown in the examples in the notes for JavaScript objects.
  • Before being inserted into a table cell, the mpg must be calculated and not be part of the data objects.
  • round the calculation to 1 decimal place
Altering the DOM.
There is a program similar to this assignment given in the lecture notes for the week that discusses the Document Object
Model. If you haven't already, you might study those notes and that example before trying this assignment. But you will also
need to be familar with Object literals and assigning an event handler function to a HTML button using JavaScript. So, hopefully
you've kept to the schedule in terms of reading the lecture notes.
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, for example.
Destination
Miles
Gallons
Chicago
329
10.6
St. Louis
284
10.5
Indianapolis
122
3.7
Nashville
191
6.4
Cincinnati
132
3.9
Transcribed Image Text:Altering the DOM. There is a program similar to this assignment given in the lecture notes for the week that discusses the Document Object Model. If you haven't already, you might study those notes and that example before trying this assignment. But you will also need to be familar with Object literals and assigning an event handler function to a HTML button using JavaScript. So, hopefully you've kept to the schedule in terms of reading the lecture notes. 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, for example. Destination Miles Gallons Chicago 329 10.6 St. Louis 284 10.5 Indianapolis 122 3.7 Nashville 191 6.4 Cincinnati 132 3.9
When a button is clicked the array of objects should be inserted into a HTML table with 4 columns: Destination, Miles, Gallons,
and MGP. Here is the page before the button is clicked.
Trip Data
Display Data
Destination
MIlles
Gallons
MPG
After the button is clicked, your program calls a function that reads the data from the array, calculates the miles per gallon for
each trip , then inserts the appropriate destination, miles, gallons, and mpg into a table row. This should result in a table with a
header row and 5 rows of data. Like this.
Trip Data
Display Data
Destination
Mlles
Gallons
MPG
Chicago
329
10.6
31.0
St. Louis
284
10.5
27.0
Indianapolis
122
3.7
33.0
Nashville
191
6.4
29.8
Cincinnati
132
3.9
33.8
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.
Transcribed Image Text:When a button is clicked the array of objects should be inserted into a HTML table with 4 columns: Destination, Miles, Gallons, and MGP. Here is the page before the button is clicked. Trip Data Display Data Destination MIlles Gallons MPG After the button is clicked, your program calls a function that reads the data from the array, calculates the miles per gallon for each trip , then inserts the appropriate destination, miles, gallons, and mpg into a table row. This should result in a table with a header row and 5 rows of data. Like this. Trip Data Display Data Destination Mlles Gallons MPG Chicago 329 10.6 31.0 St. Louis 284 10.5 27.0 Indianapolis 122 3.7 33.0 Nashville 191 6.4 29.8 Cincinnati 132 3.9 33.8 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.
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY