Skip to content
12 changes: 12 additions & 0 deletions .idea/JavaScript-I.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

150 changes: 150 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "0.1.0",
"command": "node",
"isShellCommand": true,
"args": [
"--harmony"
],

"tasks": [
{
"taskName": "runFile",
"suppressTaskName": true,
"showOutput": "always",
"problemMatcher": "$jshint",
"args": ["${file}"]
}
]
}
18 changes: 18 additions & 0 deletions assignments/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "0.1.0",
"command": "node",
"isShellCommand": true,
"args": [
"--harmony"
],

"tasks": [
{
"taskName": "runFile",
"suppressTaskName": true,
"showOutput": "always",
"problemMatcher": "$jshint",
"args": ["${file}"]
}
]
}
38 changes: 30 additions & 8 deletions assignments/arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,54 @@ let inventory = [{"id":1,"car_make":"Lincoln","car_model":"Navigator","car_year"

// ==== 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*` );
console.log(`Car 33 is a ${inventory[32].car_year} ${inventory[32].car_make} ${inventory[32].car_model}`);

// ==== 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();
console.log(`The last car in the invetory is a ${inventory[inventory.length -1].car_make} ${inventory[inventory.length -1].car_model}`);

// ==== 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 = [];
console.log();
for (let i = 0; i < inventory.length; i++) {
carModels.push(inventory[i].car_model); // 1,2,3,4
}
carModels.sort();
console.log(carModels);

// ==== 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();
for (let i = 0; i < inventory.length; i++) {
carYears.push(inventory[i].car_year); // 1,2,3,4
}
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();

/* for (let i = 0; i < inventory.length; i++) {
if (inventory[i].car_year < 2000){
oldCars.push(inventory[i].car_year); // 1,2,3,4
}
} */
for (let i = 0; i < inventory.length; i++) {
inventory[i].car_year < 2000 ? oldCars.push(inventory[i].car_year) : null;
}

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();


/* let BMWAndAudi = [];
for (let i = 0; i < inventory.length; i++) {
if (inventory[i].car_make === "BMW" || inventory[i].car_make === "Audi" ){
BMWAndAudi.push(inventory[i]); // 1,2,3,4
}
} */

let BMWAndAudi = inventory.filter((el) => el.car_make == "BMW" || el.car_make == "Audi");
console.log(JSON.stringify(BMWAndAudi));
61 changes: 56 additions & 5 deletions assignments/function-conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,79 @@
// let myFunction = function () {
// console.log("Function was invoked!");
// };
// myFunction();

/*
let myFunction = () => {
console.log("Function was invoked!");
}
*/

let myFunction = () => console.log("Function was invoked!");

myFunction();



// let anotherFunction = function (param) {
// return param;
// };
// anotherFunction("Example");

/* let anotherFunction = (param) => {
param;
}
*/
let anotherFunction = (param) => console.log(param);

anotherFunction("Example");

// let add = function (param1, param2) {
// return param1 + param2;
// };
// add(1,2);

/*
let add = (param1, param2) => {
console.log(param1 + param2);
}
*/

let add = (param1, param2) => console.log(param1 + param2);

add(1,2);

// let subtract = function (param1, param2) {
// return param1 - param2;
// };
// subtract(1,2);

/* let subtract = (param1, param2) => {
console.log(param1 - param2);
}
*/

let subtract = (param1, param2) => console.log(param1 - param2);

subtract(1,2);


// Stretch

// exampleArray = [1,2,3,4];
exampleArray = [1,2,3,4];
// const triple = exampleArray.map(function (num) {
// return num * 3;
// });
// console.log(triple);

/* let triple = (num) => {
return num * 3;
}
*/

/* There is some explanation missing here for me to fully understand what the requirements are. Is handling arrays required? */
let triple = (arry) => {
tripleArry = [];
for (let i = 0; i < arry.length; i++) {
tripleArry.push(arry[i] * 3);
}
return tripleArry;
}

console.log(triple(exampleArray));
Loading