Skip to content

Stella edelmann #867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
86 changes: 75 additions & 11 deletions assignments/arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,94 @@ let inventory = [

// ==== Challenge 1 ====
// The dealer can't recall the information for a car with an id of 33 on his lot. Help the dealer find out which car has an id of 33 by logging the car's year, make, and model in the console log provided to you below:
console.log(`Car 33 is a *car year goes here* *car make goes here* *car model goes here*`);


const findCar = (carInventory, id) => {
for (i = 0; i < carInventory.length; i++) {
if (carInventory[i].id === id) {
return "Car " + id + " is a " + carInventory[i].car_year + " " + carInventory[i].car_make + " " + carInventory[i].car_model;
}
}
}
console.log(findCar(inventory, 33));


// ==== Challenge 2 ====
// The dealer needs the information on the last car in their inventory. What is the make and model of the last car in the inventory? Log the make and model into the console.
let lastCar = 0;
console.log();

const lastCar = [0];
const last= inventory[inventory.length - 1];
console.log(last);



// ==== Challenge 3 ====
// The marketing team wants the car models listed alphabetically on the website. Sort all the car model names into alphabetical order and log the results in the console
let carModels = [];
let carModelsSorted = [];
console.log();



let carModels = ["Geo", 'Oldsmobile', 'Mazda', 'Chevrolet', 'Jeep','Eagle','Toyota', 'BMW', 'Cadillac', 'Infiniti', 'Suzuki', 'Mercury', 'Pontiac', 'Dodge',
'Ford', 'Chrysler', 'Volvo', 'Lotus', 'GMC', 'Mercedes-Benz', 'Audi', 'Volkswagen', 'Lincoln' ];

function alphabeticalOrder (carModels){

let carModelsSorted = carModels.sort(
);
console.log(carModelsSorted);
return carModelsSorted;
}
alphabeticalOrder(['Geo', 'Oldsmobile', 'Mazda', 'Chevrolet', 'Jeep','Eagle','Toyota', 'BMW', 'Cadillac', 'Infiniti', 'Suzuki', 'Mercury', 'Pontiac', 'Dodge',
'Ford', 'Chrysler', 'Volvo', 'Lotus', 'GMC', 'Mercedes-Benz', 'Audi', 'Volkswagen', 'Lincoln'])



// ==== Challenge 4 ====
// The accounting team needs all the years from every car on the lot. Create a new array from the dealer data containing only the car years and log the result in the console.
let carYears = [];
console.log();


inventory.push('car_year');
let carYears = ['1997', '1992','1998', '2012', '1996', '2009', '2008', '1995','2007', '1999', '2001', '2010', '1983', '1990', '1995', '1987', '2004', '1997','2000', '1994', '1985', '2003','2005', '1964', '2011', '1991', '1965', ];
console.log(carYears);



// ==== Challenge 5 ====
// The car lot manager needs to find out how many cars are older than the year 2000. Using the carYears array you just created, find out how many cars were made before the year 2000 by populating the array oldCars and logging it's length.
let oldCars = [];
console.log();
carYears.sort(function(a,b){
return a - b;
});
console.log(carYears)

// let oldCarYears = ["1964", "1965", "1983", "1985", "1987", "1990", "1991", "1992", "1994", "1995", "1995", "1996", "1997", "1997", "1998", "1999", "2000", "2001", "2003", "2004", "2005", "2007", "2008", "2009", "2010", "2011", "2012"];
const oldCars =
inventory.filter(function(currentValue){
return currentValue.car_year < 2000 ;
})
console.log(oldCars.length);

// ==== Challenge 6 ====
// A buyer is interested in seeing only BMW and Audi cars within the inventory. Return an array that only contains BMW and Audi cars. Once you have populated the BMWAndAudi array, use JSON.stringify() to show the results of the array in the console.
let BMWAndAudi = [];
console.log();
const audiFilter =
inventory.filter(function(currentValue){
return currentValue.car_make === "Audi";
})
const BMWFilter =
inventory.filter(function(currentValue){
return currentValue.car_make === "BMW"
})
// function getValues(firstValue, secondValue) {
// return [getFirstValue(), getSecondValue()];
// }
// const{first, second} = getValues();

// // BMWAndAudi.forEach(function(items){
// // return BMWAndAudi.push(`${items.car_make} ${items.car_model}`);

// });
console.log(BMWFilter);
console.log(audiFilter);
console.log(BMWAndAudi);


//if cartype =bmw else audi put into one array
59 changes: 58 additions & 1 deletion assignments/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,83 @@ const example = {

// Write your intern objects here:

const interns = {
id: "idnum",
name: "intername",
gender: "MF",
email: "internemail",
}



const person1 = {
id: 1,
name: "Mitzi",
gender: 'F',
email: "mmelloy0@psu.edu",
}
const person2 = {
id: 2,
name: "Kennan",
gender: 'M',
email: "kdiben1@tinypic.com",
more: function(speak) {
console.log(`${this.name} says ${speak}`);
}
}
const person3 = {
id: 3,
name: "Keven",
gender: 'M',
email: "kmummery2@wikimedia.org",
}
const person4 = {
id: 4,
name: "Gannie",
gender: 'M',
email: "gmartinson3@illinois.edu",
}
const person5 = {
id: 5,
name: "Antonietta",
gender: 'F',
email: "adaine5@samsung.com",
math: function(num1,num2){
console.log(`${this.name} 7 * 7 is ${num1*num2}`);
}
}
person2.more("Hello, my name is Kennan!");
person5.math(7, 7);


// ==== Challenge 2: Reading Object Data ====
// Once your objects are created, log out the following requests from HR into the console:

// Mitzi's name
console.log(person1.name);

// Kennan's ID
console.log(person2.id);

// Keven's email
console.log(person3.email);

// Gannie's name
console.log(person4.name);

// Antonietta's Gender
console.log(person5.gender);

// ==== Challenge 3: Object Methods ====
// Give Kennan the ability to say "Hello, my name is Kennan!" Use the console.log provided as a hint.
// console.log(kennan.speak());




// Antonietta loves math, give her the ability to multiply two numbers together and return the product. Use the console.log provided as a hint.
//console.log(antonietta.multiplyNums(3,4));

//****See above

// === Great work! === Head over to the the arrays.js. You may come back and attempt the Stretch Challenge once you have completed the challenges in arrays.js and function-conversion.js.

Expand Down