Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not have lesson_04 content in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I take it out?

Empty file.
Empty file.
22 changes: 22 additions & 0 deletions lesson_06/brooklynharden/abbreviation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

function isValidAlphaAbbreviation(word:string, abbr:string):boolean{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to avoid abbreviations for variable names (ironic in this case, right)?

let i:number = 0; //keep the index of the word
for(let j=0; j<abbr.length;j++){
const abbrChar=abbr[j];

/* We add 1 to shift the range, 'a'.charCodeAt(0) - 'a'.charCodeAt(0) = 0 ,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use single line comments here (//).

because 97-97 = 0.
Adding the '1' shifts it to a===1, which is what we want.
*/
const skip =abbrChar.charCodeAt(0) - 'a'.charCodeAt(0) + 1 ;
if(word[i] === abbrChar){
i++; //if the current word letter and the current abbrchar match match go to the next letter
}else{
i+=skip; // Otherwise, treat abbrChar as a letter abbreviation and skip that many characters
}
}
return i === word.length;
}

console.log(isValidAlphaAbbreviation("substitution", "sjn")); //true
console.log(isValidAlphaAbbreviation("test", "ab")); //false
2 changes: 1 addition & 1 deletion lesson_06/expression/.env.test
Original file line number Diff line number Diff line change
@@ -1 +1 @@
HW_VERSION=your assigned version here
HW_VERSION=B
21 changes: 20 additions & 1 deletion lesson_06/expression/src/expression_calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,29 @@ export class ExpressionCalculator {
/** Returns a calculation involving a, b, c, d, and 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 addition: number = this.add(a, b);
const power: number = this.pow(addition, c);
const multiplication: number = this.multiply(d, e);
const combine: number = this.divide(power, multiplication);
return combine;
}

pow(base: number, exponent: number): number {
return Math.pow(base, exponent);
}

add(a: number, b: number): number {
// const addition: number = a + b;
return a + b;
}

multiply(d: number, e: number): number {
// const multiplication: number = d + e;
return d * e;
}

divide(a: number, b: number): number {
// const multiplication: number = d + e;
return a / b;
}
}