-
Notifications
You must be signed in to change notification settings - Fork 5
Completed Lab #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
base: main
Are you sure you want to change the base?
Completed Lab #1
Conversation
kburd
left a comment
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.
Great work! 97%
| @@ -1,21 +1,94 @@ | |||
| class ArrayUtils{ | |||
|
|
|||
| isEmpty(array){return false;} | |||
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.
This works in JS but won't work in other languages, just a heads up
| if(arr1.length > arr2.length) { | ||
| for(let i = 0; i < arr1.length; i++) { | ||
| if(arr1[i] !== arr2[i]) { | ||
| mismatch ++; |
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.
If this is found, you could return false instead of breaking, achieves the same goal
| break; | ||
| } | ||
| } | ||
| if(match != null) { |
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.
You could start match at -1 and return the final value of match instead of checking if match is null
| reverse(original){ | ||
| let opposite = []; | ||
| for(let i = 0; i < original.length; i++) { | ||
| opposite.unshift(original[i]); |
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.
Nice usage of built in functions 👍
|
|
||
| equals(arr1, arr2){return false;} | ||
| equals(arr1, arr2){ | ||
| let mismatch = 0; |
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.
If the arrays have different lengths than they can't be equal (-3)
No description provided.