-
Notifications
You must be signed in to change notification settings - Fork 1
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
EventScoreAPI #11
base: ms-training-2
Are you sure you want to change the base?
EventScoreAPI #11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely on the right track with your algorithm.
|
||
describe('EventScore API', () => { | ||
it('Returns an entire array if it is five events or less', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth having tests for edge cases: arrays of length 0 and 5.
src/index.ts
Outdated
} else tempCount += 1 | ||
|
||
if (i > 4) { | ||
if (eventType[i - 1] === "screenshot") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you want to subtract from tempCount the most recent value added?
} else { | ||
this.eventArr.map((event, i) => { | ||
const { eventType } = event | ||
if (eventType === "screenshot") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, can definitely refactor the conversion of eventType to a scoring value.
|
||
public calcHighestScoreArrSequence = (): ReadonlyArray<Event> => { | ||
let tempCount: number = 0 | ||
let highestScoreArr: ReadonlyArray<Event> = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While insignificant in this case, as highestScoreArr is going to have max length of 5, it is possible to solve this without storing the returned highestScoreArr, and instead just directly return it.
What this does: