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
58 changes: 53 additions & 5 deletions arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,79 @@ let inventory = [

// console.log(`Car 33 is a *car year goes here* *car make goes here* *car model goes here*`);


let car33 = [];
for(let i =0; i<inventory.length; i++){
if(inventory[i].id == 33){
//car33.push(inventory[i].id)
car33.push(inventory[i].car_make)
car33.push(inventory[i].car_model)
car33.push(inventory[i].car_year)
}
}
console.log("Car 33 is "+ car33)

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

// Waxay rabaan inay ogaadaan macluumaadka gaariga ugu dambeeyay. Waxaa ka mid ah inay noocuu yahay (make) iyo modelka gaariga ugu dambeeyay.

const lastCar = [];
for(let i =0; i<inventory.length; i++){
if(inventory[i].id == inventory.length ){
lastCar.push(inventory[i].car_make)
lastCar.push(inventory[i].car_model)
}
}
console.log("last car is "+lastCar)

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

// Dadka qaabilsan xayaysiinta ayaa rabo in gawaarida loo soo bandhigo xarfaha habkey iskugu xigaan (alphabetically) si ay website-ka u galiyaan. Magacyada gawaawida oo dhan isku habee si A-Z ah kadibna console.log ku samee.

inventory.sort((a,b) =>{
if(a.car_make<b.car_make){
return -1
}else if(a.car_make>b.car_make){
return 1;
}else{
return 0
}
}

);
console.log(inventory)


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

// Dadka qaabilsan xisaabinta ayaa rabo inay ogaadaan sanadyada gawaarida oo dhan. Array cusub samee, kadibna ku shub sanadyada gawaarida oo dhan kadibna console.log ku samee.

const years =[];
for(let i=0; i<inventory.length; i++){
if(inventory[i].car_year == inventory[i].car_year){
years.push(inventory[i].car_year)
}
}
console.log("yaers are "+years.length)
// ==== Challenge 5 ====
// The car lot manager needs to find out how many cars are older than the year 2000. Find out how many cars were made before the year 2000 by populating the array oldCars and logging it's length.

// Qofka maamulo ganacsiga ayaa rabo inuu ogaado inta gaari oo ka horeysay sanadkii 2000. Isticmaal array 'oldCars', kuna shub gawaarida ka horeysay 2000. Kadib console log ku samee.

const oldCars = [];
for(let old =0; old < inventory.length; old++){
if(inventory[old].car_year>2000){
oldCars.push(inventory.length)
}
}
console.log("cars that have older than 2000 are "+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.

// Qof rabo inuu gaari gato ayaa rabo inuu ogaado inta BMW iyo Audi yaalo. Array 'BMWAndAudi' la dhaho ku shub dhamaan gawaarida BMW iyo Audi. Kadib adigoo isticmaalaayo JSON.stringify() console.log ku samee.
const BMWAndAudi= [];
for(let i = 0; i<inventory.length; i++){
if(inventory[i].car_make == "Audi" || inventory[i].car_make == "BMW"){
BMWAndAudi.push(inventory[i].car_make)
}
}
console.log(JSON.stringify(BMWAndAudi.length));

45 changes: 36 additions & 9 deletions basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ Do the following:

HINT: look up the Number method / Raadi Number Method wax la dhaho
*/


/*
let string = "199";
string = 1999;
console.log(string)
/*
Task: Mood Checker

Do the following:
Expand All @@ -19,22 +20,32 @@ Do the following:
3. Else just print 'So moody!' / Hadii kale 'So Moody!' soo saar.

*/

const mood = prompt("Qor waxaad aad dareemesid");
if(mood=="happy"){
console.log("yey me too!")
}else if(mood=="sad"){
console.log("Aw cheer up")
}else{
console.log("so moody")
}

/*
Task: Odd or Even / kisi ama dhaban

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.

Adigoo 'if/else' isticmaalaayo hubi in nambar uu yahay 'kisi ama dhaban', kadi console log ku samee adigoo sheegaayo midkuu yahay

*/

var num = 16; // You can change this number! / Number-kaan ku bilow

// write your conditions here / Code-kaada halkaan ku qor


if(num % 2==0 ){
console.log("the number is even ")
}else{
console.log("the number is odd")
}



Expand Down Expand Up @@ -92,7 +103,17 @@ It's okay for it to be slow.


*/

for (let i = 1; i<=100; i++){
if(i % 3 === 0 && i % 5 ===0){
console.log("fizzBuzz")
}else if(i % 3 === 0){
console.log("fizz")
}else if(i % 5 ===0){
console.log("Buzz")
}else{
console.log("prime")
}
}

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

Expand All @@ -107,6 +128,12 @@ Using the vowelCounter function below do the following:
*/


function vowelCounter(/*add your code here*/) {
/*add your code here*/
function vowelCounter(Counter) {






}

29 changes: 29 additions & 0 deletions functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ let add = function (param1, param2) {
add(1,2);

*/
const myFunction = () =>{
console.log("function was invoked")
}
myFunction();
//? ___________________________________________________
let anotherFunction = (param) => param;
console.log(anotherFunction("Name"))
//!_______________________________________
const add = (param1, param2) =>{
return param1 + param2;
}
console.log(add(1,2));




Expand All @@ -51,4 +64,20 @@ Use the game function below to do the following:

function game(user, computer){
/*add your code here*/
if(user === computer){
console.log("it's atie")
}else if(user === 'rock' && computer === 'paper'){
console.log("you win")
}else if(user === 'paper' && computer === 'rock'){
console.log("you lose")
}else if(user === 'rock' && computer === 'scissors'){
console.log("you win")
}else if(user === 'scissors' && computer === 'rock'){
console.log("you lose")
}else if(user === 'scissors' && computer === 'paper'){
console.log("you win")
}else if(user === 'paper' && computer === 'scissors'){
console.log("you lose")
}
}
console.log(game('scissors', 'rock'))
52 changes: 47 additions & 5 deletions objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,68 @@ const example = {

// Write your intern objects here:

const interns = {
intern1 : {
id: 1,
email: 'mmelloy0@psu.edu',
name: 'Mitzi',
gender: 'F',
},
intern2 : {
id: 2,
email: 'kdiben1@tinypic.com',
name: 'kennan',
gender: 'M',
speak: function () {
return `hello my name is ${this.name}`;
}
},
intern3 : {
id: 3,
email: 'kmummery2@wikimedia.org',
name: 'keven',
gender: 'M',
},
intern4 : {
id: 4,
email: 'gmartinson3@illinois.edu',
name: 'gannie',
gender: 'M',
},
intern5 : {
id: 5,
email: 'adaine5@samsung.com',
name: 'Antonietta',
gender: 'F',
multiply: function(num1, num2){
return num1 * num2;
}
},
}

// ==== 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(interns.intern1.name)
// Kennan's ID

console.log(interns.intern2.id)
// Keven's email

console.log(interns.intern3.email)
// Gannie's name

console.log(interns.intern4.name)
// Antonietta's Gender

console.log(interns.intern5.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(interns.intern2.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));
console.log(interns.intern5.multiply(2,4))

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