I have been given a task from school.I've been asked to create a program that will keep track of how many books are sold and price of each book.This program should allow me to enter each book name and price. It should also calculate the total price of the books and display it on screen.

I am new to Javascript and no idea where to start, apart from the fact it has to do with Arrays?

I've been asked to create a program that will keep track of how many books are sold and price of each book. This program should allow me to enter each book name and price. It should also calculate the total price of the books and display it on screen.

I am new to Javascript and no idea where to start, apart from the fact it has to do with Arrays?

Any help will be much appreciated!

We typically do not provide code for class assignments here, since the whole purpose of such assignments is for you to learn by making use of what your teacher has provided.Your course tutor is best placed to give you what you need.

If there is anything specific that you would like to know more about though, we'll be happy to help.

We typically do not provide code for class assignments here, since the whole purpose of such assignments is for you to learn by making use of what your teacher has provided.Your course tutor is best placed to give you what you need.

If there is anything specific that you would like to know more about though, we'll be happy to help.

I understand, but it's not an assignment. Its more of something my former teacher has challenged me too! I suppose the main thing I wanted to know was how I can build an array that will let me enter any number of books. For example I could enter 2 or 15.. I have no idea how to set that up.

I understand, but it's not an assignment. Its more of something my former teacher has challenged me too! I suppose the main thing I wanted to know was how I can build an array that will let me enter any number of books. For example I could enter 2 or 15.. I have no idea how to set that up.

Typically you would place the books array somewhere that it can be easily accessed. What used to be done is to make it a global array, but that's not a good practice these days after we learn that globals should be kept to an absolute minimum, so a good place to store the array is as a property on the form that you use to to enter the information.

Typically you would place the books array somewhere that it can be easily accessed. What used to be done is to make it a global array, but that's not a good practice these days after we learn that globals should be kept to an absolute minimum, so a good place to store the array is as a property on the form that you use to to enter the information.

`html

...

`

`javascript

var form = document.getElementById('bookSale');form.books = [];

`

If I use the Javascript code then after " form.books = [] " I would just place the prompt box, right? The thing I don't quite understand is that after that say for example the user put in 3 books, how would I be able to give them the option to say that's all today because otherwise the prompt box would keep repeating wouldn't it?

If I use the Javascript code then after " form.books = [] " I would just place the prompt box, right? The thing I don't quite understand is that after that say for example the user put in 3 books, how would I be able to give them the option to say that's all today because otherwise the prompt box would keep repeating wouldn't it?

It would be best to flowchart out all of the possible behaviour of someone using this. That way, once you fully know what is expected, you can craft together a working solution that meets those needs.