Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a new program ( HTML , CSS , and JavaScript ) This one should keep track of how many calories you have eaten. It

Write a new program (HTML, CSS, and JavaScript)
This one should keep track of how many calories you have eaten.
It should allow the user to enter a food name and a number of calories.
Each time they enter a new item, a food object should be created and added to an array.
Write out the updated contents of the array in the console.log so that you can verify your code is correct
at this point.
Also, in that same click event, you should update a display on the screen that shows the user the total
number of calories they have consumed.
(My version creates 2 food items, a banana and hot dog when I first start the program, so you will see
that when I add one item with 200 calories, there are already 3 items in my object list and the calorie
output shows 670. You are not required to do that, but I suggest you do.)
Tip: in your constructor, use
this.calories = parseInt(pCalories); // that forces the input value to be treated as number, not a string
My program on startup:
My program just before I click Submit:
My program after clicking to add 1 item:
image text in transcribed

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

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

1. Identify the sources for this conflict.

Answered: 1 week ago

Question

3. The group answers the questions.

Answered: 1 week ago