
Lab 18 was a unique lab, being that it mainly dealt with JS and the console rather than HTML and CSS. We were to create tables in the console with a list of famous inventors throughout history and arrange them in certain orders like alphabetically or date. The first thing we did was create a variable that stored multiple objects, these objects being the inventors with properties like name and birth date. Once this variable, var inventors or const inventors, was created the filtering process began. The first table we wanted was a table of inventors born in the 1500s. To make the table we used .filter() function of JS. Using this line of code, const fifteen = inventors.filter(inventor => (inventor.year >= 1500 && inventor.year < 1600)); , we basically tell the console to create a new array in the variable fifteen that stores only the objects from the inventor array which had their year properly equal to a number between 1500 and 1600. This array was used to create a table in the console by using the console.table() method, the parameter being the array. In a similar fashion, I created another array using .sort() to create a table of the inventors in order of first/last name, birthday, and years lived. Using console.table() again, I created a table of the list of all street names containing "de" in Paris and a list of transportation.
These skills are important for a web designer because they can be used to organize data in a website. If a website has many active users with accounts, for example, these techniques can be used to sort the users by some attribute, for example, frequency of use. Organizing the data can help tell a coherent story and may even help improve they website.
Comments
Post a Comment