Search the Community
Showing results for tags 'javascript book'.
-
Hi Larry A topic I would like to see in your JavaScript book is multidimensional arrays. As I want to know how to add, update and delete an array of JavaScript custom objects. It would therefore be good to see a specific example of this in your book. Why you may well ask? Recently, I have been attempting to modify a nutrition program that I found on the internet to this end but to no avail. The JavaScript nutrition program I am referring to adds up all the various totals for eight nutrient values including protein, fats and carbohydrates from the various food groups - very useful for the health conscious. This also involves a user selecting the amount for each food item from a drop down list. Anyway, here is part of the list of array objects: foodgroup[1]=new food("Apple Juice",15,0,0,59,0,125,1,3); foodgroup[2]=new food("Prune Juice",24,0,0,99,3,301,1,4); foodgroup[3]=new food("Grapefruit Juice",11,0,0,44,0,208,1,2); foodgroup[4]=new food("Cranberry Juice",19,0,0,76,0,15,1,3); - - foodgroup[101]=new food("Vegetable Oil 8.1 cal/cc",0,0,27,2430,0,0,0,0); The problem that I have discovered occurs when you want to change the data structures in the list of array objects in anyway. If you want to add a food group, delete a food group that you don’t eat anymore or change the nutirent data values themselves with more accurate data, it can become a very cumbersome and tedious process. It can take a fair while, even hours and days especially if you have 29 nutrients or more! This could be expedited in my opinion with the inclusion of add, update and delete buttons within the user interface itself. Nevertheless, this nutrition program uses JavaScript coding like document.write to output results. You mentioned in one of your articles that this is “bad code, bad JavaScript“ but I have found it to be a very useful program despite it limitations in terms of changing the code to increase the number of nutrients etc. You can see this JavaScript program I am referring to hereby just pasting the following link in your browser: http://www.nafwa.org...d-software.html and then download the file NUTRIENT.ZIP Regards