Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

final save #115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
88 changes: 64 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
// ⭐️ Example Challenge start ⭐️

/**
Expand Down Expand Up @@ -37,6 +38,7 @@ function addNumbers(num1, num2) {
*/
function sayGoodbye(/* code here */) {
/* code here */
console.log('Goodbye, ' + name + ' . ' + ' Have a great day. ');
}

/**
Expand All @@ -53,8 +55,10 @@ function sayGoodbye(/* code here */) {
* Hint 1: The formula for converting celsius to fahrenheit is t*9/5 + 32 where t is the temperature in celsius.
* Hint 2: There is a very easy way to round numbers in JS. Do a google search to find out how.
*/
function temperatureCtoF(/* code here */) {
/* code here */
function temperatureCtoF (degree) {
let tempC = degree * 9/5 + 32
return Math.round(tempC);

}

/**
Expand All @@ -74,8 +78,11 @@ function temperatureCtoF(/* code here */) {
*
* Hint: You can call your `temperatureCtoF` function from inside `temperatureInF`.
*/
function temperatureInF(/* code here */) {
/* code here */
function temperatureInF(arg, unit) {
if (unit === 'F') {
return '${arg}F';
} else {
return '${temperatureCtoF(arg)}F';
}


Expand All @@ -95,8 +102,8 @@ function temperatureInF(/* code here */) {
* email: "[email protected]",
* }
*/
function makePersonObject(/* code here */) {
/* code here */
function makePersonObject({ id, name, email }) {
return {id, name, email };
}

/**
Expand All @@ -112,8 +119,8 @@ function makePersonObject(/* code here */) {
* passing { id: 1, name: 'Leia', email: '[email protected]` } as the argument,
* the returned value should look like `Hello, my name is Leia`.
*/
function getName(/* code here */) {
/* code here */
function getName(id, name, email) {
return 'Hello, my name is ${name}';
}


Expand All @@ -132,8 +139,12 @@ function getName(/* code here */) {
* passing in [ 'orange', 'grape', 'apple', 'banana', 'mango' ] as the argument,
* the returned value should be: 2.
*/
function appleIndex(/* code here */) {
/* code here */
function appleIndex(fruits) {
for (i = 0; i < fruits.length; i++) {
if (fruits[i] === 'apple') {
return i;
}
}
}

/**
Expand All @@ -151,8 +162,12 @@ function appleIndex(/* code here */) {
* passing in [ 'orange', 'apple', 'banana', 'apples', 'apple', 'mango' ] as the argument,
* the returned value should be: [ false, true, false, false, true, false ].
*/
function isItAnApple(/* code here */) {
/* code here */
function isItAnApple(fruits) {
const possibleApple = [];
for (i = 0; i < fruits.length; i++) {
possibleApple.push(fruits[i] === 'apple');
}
return possibleApple;
}


Expand Down Expand Up @@ -182,14 +197,16 @@ var inventory = [
* ### Example Array Challenge:
*
* @instructions
* get3rdCar() should return the string `The is a Land Rover Defender Ice Edition`
* get3rdCar() should return the string `The is a Land Rover Defenders Ice Edition`
*
*
* NOTE: This example has been completed for you.
**/
function get3rdCar(inventory) {
const the3rd = inventory[2];
return `The is a ${the3rd.car_make} ${the3rd.car_model}`
const the3rd = inventory[2];
return 'The is a ${the3rd.car_make} ${the3rd.car_model}'
}

// 👇 COMPLETE YOUR WORK BELOW 👇
Expand All @@ -210,9 +227,10 @@ function get3rdCar(inventory) {
* it will return `This is a Lincoln Navigator`.
*/
function getCarInfoByIndex(inventory, index) {
/* code here */
return `This is a ${inventory[index] .car_make} ${inventory[index].car_model}`;
}


/**
* ### Challenge `getLastCarInfo`
*
Expand All @@ -224,8 +242,8 @@ function getCarInfoByIndex(inventory, index) {
* For example, if getLastCarInfo is invoked passing the inventory inside /data/inventory.js,
* it will return `This is a Lincoln Town Car`.
*/
function getLastCarInfo(/* code here */) {
/* code here */
function getLastCarInfo(inventory) {
return `This is a ${inventory[inventory,length-1].car_make} ${inventory[inventory.length-1].car_model}` ;
}

/**
Expand All @@ -237,8 +255,12 @@ function getLastCarInfo(/* code here */) {
* (1) an array which is an inventory of cars like the one inside /data/inventory.js.
* getModelYears returns an array containing all the 'car_year's in the inventory.
*/
function getModelYears(/* code here */) {
/* code here */
function getModelYears(inventory) {
const getTime = [];
for (let i = 0; i < inventory.length; i++) {
getTime.push(inventory[i].car_time)
}
return getTime;
}

/**
Expand All @@ -255,8 +277,13 @@ function getModelYears(/* code here */) {
* For example, if getCarInfoById is invoked with the inventory and the number 1,
* it will return `This is a Lincoln Navigator`.
*/
function getCarInfoById(/* code here */) {
/* code here */
function getCarInfoById(inventory, Id) {
for (let i = 0; i <= inventory.length-1; i++){
if(i === (Id-1)){
return `This is a ${inventroy[i].car_make} ${inventory[i].car_model}`;
}
}

}

/**
Expand All @@ -273,8 +300,14 @@ function getCarInfoById(/* code here */) {
* with a `car_year` which is at most the given desired max year,
* in the same order as they appear in the original inventory.
*/
function getOlderCars(/* code here */) {
/* code here */
function getOlderCars(inventory , greatYear) {
let foundRetro = [];
for (let i=0; i<=inventory.length-1; i++)
{
if(maxYear >= inventory[i]);
foundRetro.push(inventory[i]);
}
return foundRetro;
}

/**
Expand All @@ -290,8 +323,14 @@ function getOlderCars(/* code here */) {
* made by either `Audi` or `Mercedes-Benz` or `Volkswagen` or `BMW`,
* in the same order as they appear in the original inventory.
*/
function getGermanCars(/* code here */) {
/* code here */
function getGermanCars(inventory) {
let getCar = [];
for(let i = 0; i <= inventory.length-1; i++) {
if(inventroy[i] car.make === 'Audi' || inventory[i].car_make === 'Mercedes-Benz' || inventory[i].car._make === 'Volkswagen' || inventory[i].car_make === 'BMW'){
getCar.push(inventory[i]);
}
}
return getCar;
}

/**
Expand Down Expand Up @@ -340,3 +379,4 @@ if (typeof exports !== 'undefined') {
if (getGermanCars) { module.exports.getGermanCars = getGermanCars }

}
}