diff --git a/index.html b/index.html index 33ca1105e..427fbb5fa 100644 --- a/index.html +++ b/index.html @@ -2,13 +2,10 @@ Exercises - - - + + + - - - + + + @@ -50,6 +60,5 @@ - diff --git a/index.js b/index.js index bdafe4c8b..544caced1 100644 --- a/index.js +++ b/index.js @@ -2,90 +2,88 @@ /** * ### Challenge `addNumbers` - * + * * @instructions * This function should be able to take two numbers as arguments * and return the result of adding them together. - * + * * For example, if we invoke `addNumbers` passing 5 and 3, * the returned value should be 8. * * NOTE: This example has been completed for you. -*/ -function addNumbers(num1, num2) { + */ +function exampleFunction(num1, num2) { return num1 + num2; } // ⭐️ Example Challenge end ⭐️ - // 👇 COMPLETE YOUR WORK BELOW 👇 // 👇 COMPLETE YOUR WORK BELOW 👇 // 👇 COMPLETE YOUR WORK BELOW 👇 /** * ### Challenge `sayGoodbye` - * + * * @instructions * This function should take an a name as an argument, * and return a string that says 'Goodbye, {name}. Have a great day.' - * + * * For example, if we invoke `sayGoodbye` * passing 'Andy' as the argument, * the returned value should look like: 'Goodbye, Andy. Have a great day.' - * -*/ + * + */ function sayGoodbye(/* code here */) { /* code here */ } /** * ### Challenge `temperatureCtoF` - * + * * @instructions * This function should take an a temperature in celsius as an argument, - * and return the temperature in fahrenheit, rounded to the nearest whole number. - * + * and return the temperature in fahrenheit, rounded to the nearest whole number. + * * For example, if we invoke `temperatureCtoF` * passing 24 as the argument, * the returned value should be: 75 - * + * * 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. -*/ + * 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 */ } /** * ### Challenge `temperatureInF` - * + * * @instructions * This function should take an a temperature and a unit (either 'F' or 'C') as arguments, - * and return the temperature in fahrenheit, rounded to the nearest whole number. - * + * and return the temperature in fahrenheit, rounded to the nearest whole number. + * * For example, if we invoke `temperatureInF` * passing 88, 'F' as the arguments, * the returned value should be: '88F' - * + * * If we invoke `temperatureInF` * passing 24, 'C' as the arguments, * the returned value should be: '75F' - * + * * Hint: You can call your `temperatureCtoF` function from inside `temperatureInF`. -*/ + */ function temperatureInF(/* code here */) { /* code here */ } - /** * ### Challenge `makePersonObject` - * + * * @instructions * This function should take an id, a name and an email as arguments, * and return an object with `id`, `name` and `email` properties. - * + * * For example, if we invoke `makePersonObject` * passing 5, 'Leia' and 'leia@leia.com' as arguments, * the returned value should look like: @@ -94,69 +92,66 @@ function temperatureInF(/* code here */) { * name: "Leia", * email: "leia@leia.com", * } -*/ + */ function makePersonObject(/* code here */) { /* code here */ } /** * ### Challenge `getName` - * + * * @instructions * This function takes as its only argument * an object containing a `name` property, * and return a string that reads `Hello, my name is {name}`, * where `{name}` is the name stored in the object. - * + * * For example, if we invoke `getName` * 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 */ } - /** * ### Challenge `appleIndex` - * + * * @instructions - * This function takes as its only argument an array + * This function takes as its only argument an array * containing strings, * and returns the index in the array of the string 'apple'. - * - * You may assume the string 'apple' will appear exactly + * + * You may assume the string 'apple' will appear exactly * once in the array. - * + * * For example, if we invoke `appleIndex` * passing in [ 'orange', 'grape', 'apple', 'banana', 'mango' ] as the argument, * the returned value should be: 2. -*/ + */ function appleIndex(/* code here */) { /* code here */ } /** * ### Challenge `isItAnApple` - * + * * @instructions - * This function takes as its only argument an array + * This function takes as its only argument an array * containing strings, * and returns an array of equal length containing the `true` - * if the corresponding entry in the original array is 'apple' + * if the corresponding entry in the original array is 'apple' * and `false` if it is anything else. - * - * + * + * * For example, if we invoke `isItAnApple` * 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 */ } - - /* // ⭐️ Example Test Data ⭐️ @@ -179,64 +174,63 @@ var inventory = [ ] */ /** - * ### Example Array Challenge: - * - * @instructions - * get3rdCar() should return the string `The is a Land Rover Defender Ice Edition` - * - * - * NOTE: This example has been completed for you. -**/ + * ### Example Array Challenge: + * + * @instructions + * get3rdCar() should return the string `The is a Land Rover Defender 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}` + return `The is a ${the3rd.car_make} ${the3rd.car_model}`; } // 👇 COMPLETE YOUR WORK BELOW 👇 // 👇 COMPLETE YOUR WORK BELOW 👇 // 👇 COMPLETE YOUR WORK BELOW 👇 - /** * ### Challenge `getCarInfoByIndex` - * + * * @instructions * getCarInfoByIndex takes two arguments: * (1) an array which is an inventory of cars like the preview above (see ⭐️ Preview Test Data ⭐️) * (2) a number which is the desired index in the array. * getCarInfoByIndex returns a string in the format `This is a {car_make} {car_model}` - * + * * 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 */ } /** * ### Challenge `getLastCarInfo` - * + * * @instructions * getLastCarInfo takes a single argument: * (1) an array which is an inventory of cars like the one inside /data/inventory.js. * getLastCarInfo returns a string in the format `This is a {car_make} {car_model} - * + * * 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 */ } /** * ### Challenge `getModelYears` - * + * * @instructions * We need the years from every car in the inventory! * getModelYears takes a single argument: * (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 */ } @@ -245,16 +239,16 @@ function getModelYears(/* code here */) { * ### Challenge `getCarInfoById` * * * THIS ONE IS A STRETCH GOAL. ATTEMPT IT ONLY AFTER * COMPLETING ALL NON-STRETCH CHALLENGES IN THE REPOSITORY! - * + * * @instructions * getCarInfoById takes two arguments: * (1) an array which is an inventory of cars like the one inside /data/inventory.js. * (2) a number which is the desired car id (see how each car has its own unique id). * getCarInfoById returns a string in the format `This is a {car_make} {car_model} - * + * * 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 */ } @@ -263,7 +257,7 @@ function getCarInfoById(/* code here */) { * ### Challenge `getOlderCars` * * THIS ONE IS A STRETCH GOAL. ATTEMPT IT ONLY AFTER * COMPLETING ALL NON-STRETCH CHALLENGES IN THE REPOSITORY! - * + * * @instructions * We need a utility to find older cars! * getOlderCars takes two arguments: @@ -272,7 +266,7 @@ function getCarInfoById(/* code here */) { * getOlderCars returns an array containing all the cars * 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 */ } @@ -281,7 +275,7 @@ function getOlderCars(/* code here */) { * ### Challenge `getGermanCars` * * THIS ONE IS A STRETCH GOAL. ATTEMPT IT ONLY AFTER * COMPLETING ALL NON-STRETCH CHALLENGES IN THE REPOSITORY! - * + * * @instructions * We need a utility to find German cars! * getGermanCars takes a single argument: @@ -289,7 +283,7 @@ function getOlderCars(/* code here */) { * getGermanCars returns an array containing all the cars * 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 */ } @@ -298,7 +292,7 @@ function getGermanCars(/* code here */) { * ### Challenge `carMaker` * THIS ONE IS A STRETCH GOAL. ATTEMPT IT ONLY AFTER * COMPLETING ALL NON-STRETCH CHALLENGES IN THE REPOSITORY! - * + * * @instructions * This function takes a single odometer argument (a number) and returns an object. * The returned object has the following characteristics: @@ -306,7 +300,7 @@ function getGermanCars(/* code here */) { * it has a `drive` method that takes a distance as its argument, and * (1) causes the odometer in the object to be increased by the distance, * (2) returns the updated value of the `odometer`. -*/ + */ function carMaker(/* code here */) { /* code here */ } @@ -314,29 +308,56 @@ function carMaker(/* code here */) { /// ////// END OF CHALLENGE ///////// /// ////// END OF CHALLENGE ///////// /// ////// END OF CHALLENGE ///////// -if (typeof exports !== 'undefined') { +if (typeof exports !== "undefined") { // IGNORE: Test/Env Detected // For Node/Non-browser test env - module.exports = module.exports || {} - if (addNumbers) { module.exports.addNumbers = addNumbers } - if (sayGoodbye) { module.exports.sayGoodbye = sayGoodbye } - if (temperatureCtoF) { module.exports.temperatureCtoF = temperatureCtoF } - if (temperatureInF) { module.exports.temperatureInF = temperatureInF } - if (makePersonObject) { module.exports.makePersonObject = makePersonObject } - if (getName) { module.exports.getName = getName } - if (appleIndex) { module.exports.appleIndex = appleIndex } + module.exports = module.exports || {}; + if (addNumbers) { + module.exports.addNumbers = addNumbers; + } + if (sayGoodbye) { + module.exports.sayGoodbye = sayGoodbye; + } + if (temperatureCtoF) { + module.exports.temperatureCtoF = temperatureCtoF; + } + if (temperatureInF) { + module.exports.temperatureInF = temperatureInF; + } + if (makePersonObject) { + module.exports.makePersonObject = makePersonObject; + } + if (getName) { + module.exports.getName = getName; + } + if (appleIndex) { + module.exports.appleIndex = appleIndex; + } - if (isItAnApple) { module.exports.isItAnApple = isItAnApple } - + if (isItAnApple) { + module.exports.isItAnApple = isItAnApple; + } - - if (carMaker) { module.exports.carMaker = carMaker } - if (getCarInfoByIndex) { module.exports.getCarInfoByIndex = getCarInfoByIndex } - if (getLastCarInfo) { module.exports.getLastCarInfo = getLastCarInfo } - if (getCarInfoById) { module.exports.getCarInfoById = getCarInfoById } + if (carMaker) { + module.exports.carMaker = carMaker; + } + if (getCarInfoByIndex) { + module.exports.getCarInfoByIndex = getCarInfoByIndex; + } + if (getLastCarInfo) { + module.exports.getLastCarInfo = getLastCarInfo; + } + if (getCarInfoById) { + module.exports.getCarInfoById = getCarInfoById; + } - if (getModelYears) { module.exports.getModelYears = getModelYears } - if (getOlderCars) { module.exports.getOlderCars = getOlderCars } - if (getGermanCars) { module.exports.getGermanCars = getGermanCars } - + if (getModelYears) { + module.exports.getModelYears = getModelYears; + } + if (getOlderCars) { + module.exports.getOlderCars = getOlderCars; + } + if (getGermanCars) { + module.exports.getGermanCars = getGermanCars; + } }