Skip to content
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
75 changes: 46 additions & 29 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ function addNumbers(num1, num2) {
* the returned value should look like: 'Goodbye, Andy. Have a great day.'
*
*/
function sayGoodbye(/* code here */) {
/* code here */
function sayGoodbye(name) {
return(`Goodbye, ${name}. Have a great day.`)
}
console.log(sayGoodbye(`Terry`));

/**
* ### Challenge `temperatureCtoF`
Expand All @@ -53,10 +54,11 @@ 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(celsius) {
return(Math.round(celsius*(9/5)+32));
}

console.log(temperatureCtoF(24));
/**
* ### Challenge `temperatureInF`
*
Expand All @@ -74,10 +76,11 @@ function temperatureCtoF(/* code here */) {
*
* Hint: You can call your `temperatureCtoF` function from inside `temperatureInF`.
*/
function temperatureInF(/* code here */) {
/* code here */
}

function temperatureInF(temp,unit) {
if (unit===`C`){return(Math.round(temp*(9/5)+32))+`F`}else{return(`${temp}${unit}`)}
}
console.log(temperatureInF(24,`C`));

/**
* ### Challenge `makePersonObject`
Expand All @@ -95,10 +98,18 @@ function temperatureInF(/* code here */) {
* email: "leia@leia.com",
* }
*/
function makePersonObject(/* code here */) {
/* code here */
function makePersonObject(idNum, firstName, address) {
// const object={
// id:idNum,
// name:firstName,
// address:address
// }
return(
`id:${idNum},\nname:${firstName},\nemail:${address},`
)

}

console.log(makePersonObject(5680,`Terry Edwards Jr`,`terryedwardsjr113@gmail.com`));
/**
* ### Challenge `getName`
*
Expand All @@ -112,11 +123,15 @@ function makePersonObject(/* code here */) {
* passing { id: 1, name: 'Leia', email: 'leia@leia.com` } as the argument,
* the returned value should look like `Hello, my name is Leia`.
*/
function getName(/* code here */) {
/* code here */
function getName() {
const exObject={
id: 5680,
name:`Terry`,
email:`terry@terry.com`
};
return(`Hello, my name is `+exObject.name)
}


console.log(getName());
/**
* ### Challenge `appleIndex`
*
Expand All @@ -132,10 +147,11 @@ 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() {
let array=[`orange`, `grape`,`apple`, `bananan`, `mango`]
return(array.indexOf(`apple`))
}

console.log(appleIndex())
/**
* ### Challenge `isItAnApple`
*
Expand All @@ -151,13 +167,13 @@ 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(array) {

const fruits=[ 'orange', 'apple', 'banana', 'apples', 'apple', 'mango' ];
for (i=0; i<fruits.length; i++){if (fruits[i]==='apple'){console.log (true);}else{console.log(false);}}
}
console.log(isItAnApple('fruits'))



/*
// ⭐️ Example Test Data ⭐️

var inventory = [
Expand All @@ -177,7 +193,7 @@ var inventory = [
{ id: 14, car_make: "Dodge", car_model: "Ram Van 1500", car_year: 1999 }
/// ... Truncated
]
*/

/**
* ### Example Array Challenge:
*
Expand All @@ -196,7 +212,6 @@ function get3rdCar(inventory) {
// 👇 COMPLETE YOUR WORK BELOW 👇
// 👇 COMPLETE YOUR WORK BELOW 👇


/**
* ### Challenge `getCarInfoByIndex`
*
Expand All @@ -209,10 +224,11 @@ function get3rdCar(inventory) {
* For example, if getCarInfoByIndex is invoked with the inventory and the number 0,
* it will return `This is a Lincoln Navigator`.
*/
function getCarInfoByIndex(inventory, index) {
/* code here */
function getCarInfoByIndex(array,index) {
const inven=inventory[0];
return(`This is a ${inven.car_make} ${inven.car_model}`)
}

console.log(getCarInfoByIndex(inventory,inventory[0]))
/**
* ### Challenge `getLastCarInfo`
*
Expand All @@ -224,8 +240,9 @@ 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(array) {
const invent=
return(`This is a ${inventory.car_make} ${inventory.car_model}`)
}

/**
Expand Down