Skip to content
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
37 changes: 27 additions & 10 deletions arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,47 @@ 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*`);
console.log(`Car 33 is a *2011* *Jeep* *Wrangler*`);

// ==== 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();
let lastCar = 50;
console.log('car 50 is a *1999* *Lincoln* *Town Car*');

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

// ==== 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);
}
console.log(carYears.sort());

// ==== 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].old_car);
}
}
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]) }
}
console.log(JSON.stringify(BMWAndAudi));
68 changes: 37 additions & 31 deletions basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,58 @@ Do the following:
3. Return the result

HINT: look up the Number method
*/

*/
let x="1999"
let y= Number(x);
console.log(y)

/*
Task: Mood Checker

Do the following:
1. Write a script that prompts the user for their current mood.
1. write a script that prompts the user for their current mood.
2. If the user inputs happy, print 'Yay me too!' to the console, sad print 'Aw cheer up',
3. Else just print 'So moody!'

*/


let letter = prompt("Enter your mood");

// If the letter is "Happy"
if (letter === "happy") {
console.log ("Yay me too!")

// If the letter is "Sad"
} else if (letter === "sad") {
console.log ("Aw cheer up.")

// If the letter is anything else
} else {
console.log ("So Moody")
}



/*
Task: Odd or Even

Use conditionals to check if a hardcoded number is odd or even, and then console.log the number is odd or even with the numbers value.

*/

var num = 16; // You can change this number!
var num = 17; // You can change this number!

// write your conditions here

if(num % 2 == 0) {
console.log("The number is even.");
}

// if the number is odd
else {
console.log("The number is odd.");
}

/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task: FIZZBUZZ 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand Down Expand Up @@ -63,32 +90,11 @@ Equals 2. Because after dividing 6 by 4, there are 2 left over from the six.
If that was confusing, don't worry. It will make more sense as you use it.
The point is: the remainder operator is useful for finding out if X is a multiple of Y. If it is, then X % Y will yield zero.
Knowing this should help you complete this assignment without any issue.


Extra Credit:

Instead of only printing "fizz", "buzz", and "fizzbuzz", add a fourth print statement: "prime".
You should print this whenever you encounter a number that is prime (divisible only by itself and one).
As you implement this, don't worry about the efficiency of the algorithm you use to check for primes.
It's okay for it to be slow.


*/
for (var i = 1; i < 101; i++) {
if (i % 15 == 0) console.log("FizzBuzz");
else if (i % 3 == 0) console.log("Fizz");
else if (i % 5 == 0) console.log("Buzz");
else console.log(i);
}


/*💪💪💪💪💪💪💪💪💪💪 Stretch 💪💪💪💪💪💪💪💪💪💪*/

//Vowel Counter - How many vowels are there?
/*
Using the vowelCounter function below do the following:
1. Receive a string as a parameter
2. Count and return the number of vowels within that string. It should handle both capitalized and uncapitalized vowels.

HINT - you may need to study next week's content on arrays
HINT - try looking up the .includes() method
*/


function vowelCounter(/*add your code here*/) {
/*add your code here*/
}
21 changes: 13 additions & 8 deletions functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,37 @@

// Take the commented ES5 syntax and convert it to ES6 arrow Syntax

var printer = () =>
console.log("Hello World");

/*

------------
function myFunction() {
console.log("Function was invoked!");
};
const sayHello = () => console.log("Hi");

sayHello()

myFunction();
----------------


let anotherFunction = function (param) {
return param;
};


anotherFunction("Example");

---------------


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

add(1,2);

*/








Expand Down
65 changes: 57 additions & 8 deletions objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,84 @@
// 5, adaine5@samsung.com, Antonietta, F

// Example format of an intern object: 1, examples@you.edu, Example, F
const example = {
id: 0,
name: "Example",
email: "examples@you.edu",
gender: "F",
}

// Write your intern objects here:

const objectMitzi = {
id: 1,
name: 'Mitzi',
email: 'mmelloy0@psu.edu',
gender: 'F',
}

const objectKennan = {
id: 2,
name: 'Kennan',
email: 'kdiben1@tinypic.com',
gender:'M',
}


const objectKeven = {
id: 3,
name: 'Keven',
email: 'kmummery2@wikimedia.org',
gender: 'M',
}

const objectGannie = {
id: 4,
name: 'Gannie',
email: 'gmartinson3@illinois.edu',
gender: 'M',
}

const objectAntionietta = {
id: 5,
name: 'Antonietta',
email: 'adaine5@samsung.com',
gender: 'F',
}



// ==== 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(objectMitzi['name']);

// Kennan's ID
console.log(objectKennan['id']);

// Keven's email

console.log(objectKeven['email']);

// Gannie's name

console.log(objectGannie['name']);

// Antonietta's Gender

console.log(objectAntionietta['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());

console.log("Hello, my name is Kennan!");


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

//console.log(Antonietta.multiplyNums);

const multiply = (num1, num2) => {
return 3 * 4;
};
let resulMultiply = multiply(3, 4);
console.log(resulMultiply);

// === 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.