Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

function Automobile( year, make, model, type this.year = year; //integer (ex. 20

ID: 3927609 • Letter: F

Question

function Automobile( year, make, model, type this.year = year; //integer (ex. 2001, 1995) this.make = make; //string (ex. Honda, Ford) this.model model; //string (ex. Accord, Focus) this.type type; //string (ex. Pickup, SUV) var automobiles new Automobile(1995, "Honda", "Accord", "Sedan"), new Automobile(1990, "Ford", "F-150", "Pickup"), new Automobile (2000, "GMC", "Tahoe", "SUV"), new Automobile(2010, "Toyota", "Tacoma", "Pickup), new Automobile (2005, "Lotus", "Elise", "Roadster"), new Automobile (2008, "Subaru", "Outback", "Wagon") /*This function sorts arrays using an arbitrary comparator. You pass it a comparator and an array of objects appropriate for that comparator and it will return a new array which is sorted with the lar gest object in index 0 and the smallest in the last index/ function sortArr( comparator, array) /*your code here/ /*A comparator takes two arguments and uses some algorithm to compare them. If the first argument is larger or greater than the 2nd it returns true, otherwise it returns false. Here is an example that works on integers/ function exComparator( intl, int2) if (int1 int2) return true } else return false;

Explanation / Answer

/*Automobile Object*/ function Automobile(year, make, model, type) { this.year = year; //integer (ex. 2001, 1995) this.make = make; //string (ex. Honda, Ford) this.model = model; //string (ex. Accord, Focus) this.type = type; //string (ex. Pickup, SUV) } /*Method: logMe for Automobile Object*/ /*Description: Prints the properties in an automobile object.*/ /*Pass a boolean of true to print type*/ Automobile.prototype.logMe = function(bool) { if (bool == true) { console.log(this.year + " " + this.make + " " + this.model + " " + this.type); } else { console.log(this.year + " " + this.make + " " + this.model + " "); } } var automobiles = [ new Automobile(1995, "Honda", "Accord", "Sedan"), new Automobile(1990, "Ford", "F-150", "Pickup"), new Automobile(2000, "GMC", "Tahoe", "SUV"), new Automobile(2010, "Toyota", "Tacoma", "Pickup"), new Automobile(2005, "Lotus", "Elise", "Roadster"), new Automobile(2008, "Subaru", "Outback", "Wagon") ]; /*This function sorts arrays using an arbitrary comparator. You pass it a comparator and an array of objects appropriate for that comparator and it will return a new array which is sorted with the largest object in index 0 and the smallest in the last index*/ function sortArr(comparator, array) { var newArr = array.slice(0); //Shallow copy of old array. Should look into implementing a deep copy prototype for future development. for (var i = 0; i auto2.year) { return true; } else { return false; } } /*This compares two automobiles based on their make. It should be case insensitive and makes which are alphabetically earlier in the alphabet are "greater" than ones that come later.*/ function makeComparator(auto1, auto2) { if (auto1.make.toLowerCase()