===== CS 328 - Week 15 Extra Example - recorded 2024-04-30 ===== ===== "TODAY" WE WILL ===== * a few comments about the JavaScript Array object (more in zyBooks Ch. 7, section 7.8) * example using JavaScript in an example involving checkboxes and a JavaScript array ===== a few bits about the JavaScript Array object ===== * why mention here? because document methods such getElementsByTagName and getElementsByClassName return an array of DOM objects meeting the criteria * creating a new empty array is straightforward: let myArray = []; * creating an array with initial contents is likewise straightforward: let myArrayVals = [val1, val2, ..., valN]; * array indices ARE 0-based let myChocolates = ["Dick Taylor", "Ghirardeli", "Sjaaks"]; myChocolates[0] == "Dick Taylor" // would be a true expression * Array provides quite a few data fields and methods -- see zyBooks Chapter 7 - Section 7.8 for more on those ...but note it has a length data field, whose value is the number of elements in the array (and methods including indexOf, reverse, sort, slice, and more!) ===== * (then see the example in js-ckbox-play.html and updateSummary.js)