diff --git a/lesson_05/dasiaenglish/lesson_05.md b/lesson_05/dasiaenglish/lesson_05.md deleted file mode 100644 index 7a6a0f288..000000000 --- a/lesson_05/dasiaenglish/lesson_05.md +++ /dev/null @@ -1,12 +0,0 @@ -## User Stories - -# Shein app --As a shopper I would like to virtually try on clothing items to see if they fit or not before purchasing. -This will help reduce returns and ensure customer satisfaction by allowing users to feel more confident in their purchases. - --As a buyer I would like to know exaclty how much I am spending, with a recommendation on what is worth my dolor, by grouping clothes a certain way. -This will help shoppers make more informed decisions and feel like they're making smart purchases, leading to a better shopping experience. - - --As a fashionesta I want a personalized stylist to creat outfits with what is in my cart, that way I can mix and match my clothes. - This will enhance the shopping experience by helping users create stylish, personalized outfits, making them more likely to buy multiple items and enjoy their purchase. \ No newline at end of file diff --git a/lesson_06/expression/src/expression_calculator.ts b/lesson_06/expression/src/expression_calculator.ts index 13cb2ca05..838d2cb55 100644 --- a/lesson_06/expression/src/expression_calculator.ts +++ b/lesson_06/expression/src/expression_calculator.ts @@ -2,10 +2,27 @@ export class ExpressionCalculator { /** Returns the calculation of ((a + b) * c) / d^e */ calculate(a: number, b: number, c: number, d: number, e: number): number { // Implement your code here to return the correct value. - return 0; + const divide = this.multiply(this.add(a, b), c) / this.pow(d, e) + return divide; } pow(base: number, exponent: number): number { return Math.pow(base, exponent); } -} + + add(a: number, b: number): number { + const sum = a + b; + return sum; + } + + divide(a: number, b: number): number { + const num = a / b; + return num; + } + + multiply(a: number, b: number){ + const num = a * b; + return num; + } + + } \ No newline at end of file diff --git a/lesson_07/conditionals/src/lesson7.ts b/lesson_07/conditionals/src/lesson7.ts index 52f45df8b..56123dd2c 100644 --- a/lesson_07/conditionals/src/lesson7.ts +++ b/lesson_07/conditionals/src/lesson7.ts @@ -7,7 +7,12 @@ import { computeLexicographicDistance } from "./util.js"; * @return True if the age corresponds to a voting age and false otherwise. */ export function canVote(age: number): boolean { - return false; + if (age >= 18) { + return true; + } else { + return false; + } + } /** @@ -23,10 +28,12 @@ export function compareStrings(a: string, b: string): number { const distance = computeLexicographicDistance(a, b); // TODO(you): Finish this method. + if (distance < 0) { + return -1; + } - return 0; + return distance; } - /** * Converts a GPA on the 4.0 scale to the corresponding letter grade using the college board * scale. See @@ -37,17 +44,46 @@ export function compareStrings(a: string, b: string): number { * @return The letter grade ("A+", "A", "A-", "B+", etc.). */ export function convertGpaToLetterGrade(gpa: number): string { - return "F"; + if (gpa === 4.0) { + return "A"; + } else if (gpa > 4.0) { + return "A"; + } else if (gpa <= 3.99 && gpa >= 3.7) { + return "A-"; + } else if (gpa <= 3.69 && gpa >= 3.3) { + return "B+"; + } else if (gpa <= 3.29 && gpa >= 3.0) { + return "B"; + } else if (gpa <= 2.99 && gpa >= 2.7) { + return "B-"; + } else if (gpa <= 2.69 && gpa >= 2.3) { + return "C+"; + } else if (gpa <= 2.29 && gpa >= 2.0) { + return "C"; + } else if (gpa <= 1.99 && gpa >= 1.7) { + return "C-"; + } else if (gpa <= 1.69 && gpa >= 1.3) { + return "D+"; + } else if (gpa <= 1.29 && gpa >= 1.0) { + return "D"; + } else { + return "F"; + } } -/** - * Computes the factorial of the given value of `n`. +/**km + * computes the factorial of the given value of `n`. * * @param n The value for which to compute the factorial. * @return The factorial of n. */ export function computeFactorial(n: number): number { - return 0; + let product = 1; + for (let i = 1; i <= n; i++) { + product *= i; + } + + return product; } /** @@ -57,7 +93,12 @@ export function computeFactorial(n: number): number { * @return The sum of all the values. */ export function addNumbers(values: number[]): number { - return 0; + let sum = 0; //initialize variable + + for (const value of values) { + sum += value; //adds value to each + } + return sum; } /** @@ -67,7 +108,21 @@ export function addNumbers(values: number[]): number { * @return An array containing the first `n` Fibonacci values. */ export function getFirstNFibonacciNumbers(n: number): number[] { - return []; + let current = 1; + let prev = 0; + + const numbers = []; + + for (let i = 1; i<=n; i++){ + numbers.push(current); + const nextNum = current + prev; // 1 + prev = current; // 1 + current = nextNum + } + + + + return numbers; } /** @@ -86,12 +141,22 @@ export function binarySearch( value: number, ): number { if (end < start) { + + // The range is not valid so just return -1. return -1; } const pivotIndex = Math.floor((start + end) / 2); // The index in the middle of the array. - + if (values[pivotIndex] === value) { + return pivotIndex; +} +else if (values[pivotIndex] > value) { + return binarySearch(values, start, pivotIndex - 1, value); +} +else { + return binarySearch(values, pivotIndex + 1, end, value); +} // TODO(you): Finish implementing this algorithm // If values[pivotIndex] is equal to value then return `pivotIndex`.