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
38 changes: 35 additions & 3 deletions arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,64 @@ let inventory = [
// Ma xasuustaan ID-ga gaariga 33 aad, ka caawi inay ogaadaan ID-ga gaariga 33aad. Waa inaa soo bandhigto sanadka gaariga, noocuu yahay (make) iyo modelka gaariga. Habkaan usoo bandhig:

// console.log(`Car 33 is a *car year goes here* *car make goes here* *car model goes here*`);
console.log(inventory[32].car_model + "is goes here" + inventory[32].car_make + "is goes here" + inventory.car_year);



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

console.log("last car_make is = " + inventory[inventory.length-1].car_make + "and car_model is " + 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

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

carModel.sort();
}

console.log(carModel);

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


let carYear = [];
for(let i = 0; i < inventory.length; i++){
carYear.push(inventory[i].car_year)
}
console.log(carYear);


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

let oldCar = [];
for (let i = 0; i < inventory.length; i++){
if (inventory[i].car_year > 2000 ){
oldCar.push(inventory[i].car_year);
console.log(oldCar)
}
}
console.log(oldCar);


// ==== 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.
let BMW_Audi = [];
for( let i =0; i < inventory.length; i++){
if(( inventory[i].car_make ==="BMW" ) || (inventory[i].car_make ==="Audi") ){
BMW_Audi.push(inventory[i].car_make);
}
}
console.log(BMW_Audi);
50 changes: 47 additions & 3 deletions basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Do the following:

HINT: look up the Number method / Raadi Number Method wax la dhaho
*/
let number = "1999";
parseInt(number);
console.log(typeof (number));


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

*/
let mood = prompt ('enter your mood today'); // - happy or -'sad'
let mood1='happy';
let mood2='sad';
if (mood==mood1){
console.log("Yay me too!");

}
else if(mood==mood2){
console.log("Aw cheer up");

}
else{
console.log("So moody!");

}

/*
Task: Odd or Even / kisi ama dhaban
Expand All @@ -31,13 +48,20 @@ Adigoo 'if/else' isticmaalaayo hubi in nambar uu yahay 'kisi ama dhaban', kadi c
*/

var num = 16; // You can change this number! / Number-kaan ku bilow
if (num%2==1){
console.log("this number is odd");
}
else {
console.log("this number is even");
}

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






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

/*
Expand Down Expand Up @@ -92,6 +116,15 @@ It's okay for it to be slow.


*/
for (let A = 1; A < 101; A++) {
if (A % 3 == 0)
console.log("Fizz");
else if (A % 5 == 0)
console.log("Buzz");
else if (A % 15 == 0)
console.log("FizzBuzz");
else console.log("the number is prime");
}


/*💪💪💪💪💪💪💪💪💪💪 Stretch 💪💪💪💪💪💪💪💪💪💪*/
Expand All @@ -107,6 +140,17 @@ Using the vowelCounter function below do the following:
*/


function vowelCounter(/*add your code here*/) {
/*add your code here*/
}
function vowelCounter(vowel) {
let count = 0;
let char = ["a", "e", "i", "o", "u" ];

for (let i = 0; i < vowel.length; i++) {
let change = vowel[i].toLowerCase();
if (char.includes(change)) {
count++;
}
}

return count;
}
console.log(vowelCounter("Hello Iqra!"));
49 changes: 48 additions & 1 deletion functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ let add = function (param1, param2) {
add(1,2);

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

myFunction();

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

anotherFunction("Example");


var add = (param1, param2) => {
return param1 + param2;
};

add(1,2);



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

function game(user, computer){
/*add your code here*/
}
if (user === "rock") {
if (computer === "rock") {
return "it's a tie";
} else if (computer === "paper") {
return "you lose!";
} else {
return "you win!";
}
} else if (user === "paper") {
if (computer === "rock") {
return "you win!";
} else if (computer === "paper") {
return "it's a tie";
} else {
return "you lose!";
}
} else {
if (computer === "rock") {
return "you lose!";
} else if (computer === "paper") {
return "you win!";
} else {
return "it's a tie";
}
}
}

const result = game("rock", "paper");

console.log(result);
63 changes: 53 additions & 10 deletions objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,70 @@ const example = {
}

// Write your intern objects here:

let interns = {
intern1 : {
id: 1,
Fname: "Mitzi",
email: "mmelloy0@psu.edu",
gender: "F",
},
intern2 : {
id: 2,
Fname: "Kennan",
email: "kdiben1@tinypic.com",
gender: "m",
},
intern3 : {
id: 3,
Fname: "Keven",
email: "kmummery2@wikimedia.org",
gender: "M",
},
intern4 : {
id: 4,
Fname: "Gannie",
email: "gmartinson3@illinois.edu",
gender: "M",
},
intern5 : {
id: 5,
Fname: "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(interns.intern1.Fname)

// Kennan's ID

console.log(interns.intern2.id)

// Keven's email

console.log(interns.intern3.email)

// Gannie's name

console.log(interns.intern4.Fname)

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

speak=function(){
return `hi my name is ${this.Fname}`
}
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));

multiplyNums=function(a,b){
return a/b;

}
console.log(interns.intern5.multiplyNums(3,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.