diff --git a/arrays.js b/arrays.js index 9a5827f..3d83d7a 100644 --- a/arrays.js +++ b/arrays.js @@ -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{ + if(a.car_makeb.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; i2000){ + 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{ + 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)); + @@ -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')) \ No newline at end of file diff --git a/objects.js b/objects.js index 9640e8c..877ab46 100644 --- a/objects.js +++ b/objects.js @@ -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. \ No newline at end of file