-
Notifications
You must be signed in to change notification settings - Fork 5
sorry.. forgot to pull request #3
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?
Changes from all commits
276720e
120cdd1
f006d7b
71bfe3a
96550f2
b2d2330
2266d26
c0ac2c8
6a39766
8a29357
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,84 @@ | ||
| class ArrayUtils{ | ||
|
|
||
| isEmpty(array){return false;} | ||
|
|
||
| append(original, value){return original;} | ||
| isEmpty(array){ | ||
| if (array.length !== 0){ | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| append(original, value){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an infinite loop, each time you add an element, the length goes up. This will happen each iteration. (-3) |
||
| for (let i = 0; i <= original.length; i ++){ | ||
| if(i === original.length -1){ | ||
| original += value | ||
| } | ||
| } | ||
|
|
||
| return original | ||
| } | ||
|
|
||
| clone(original){return original;} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returns a string instead of an array (-6) |
||
| clone(original){ | ||
| const array = [] | ||
| for(let i = 0; i <= original.length; i++){ | ||
| array += orginal | ||
| } | ||
| return array | ||
| } | ||
|
|
||
| subArray(original, from, to){return original;} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does not compile, |
||
| subArray(original, from, to){ | ||
| let output = "" | ||
| for(let i = 0; i <= original.length; i ++){ | ||
| for(let j = from[i]; j <= to[i].length; j++){ | ||
| output += j | ||
| } | ||
| } | ||
|
|
||
| return output | ||
| } | ||
|
|
||
| equals(arr1, arr2){return false;} | ||
| equals(arr1, arr2){ | ||
| if(arr1 !== arr2){ | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| fill(original, value){} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not be adding elements to an array, should be updating the existing values (-11) |
||
| fill(original, value){ | ||
| for(let i = 0; i <= original.length; i ++){ | ||
| if(i === original[i]){ | ||
| original[i] += value | ||
| } | ||
| } | ||
|
|
||
| indexOf(original, value){return -1;} | ||
| } | ||
|
|
||
| remove(original, value){return original;} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Close, Hint: |
||
| indexOf(original, value){ | ||
| for (let i = 0; i <= original.length; i ++){ | ||
| if (i === value){ | ||
| return i | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| reverse(original){} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does not work, take a look and see if your if statement is correctly locating the value (-11) |
||
| remove(original, value){ | ||
| for (let i = 0; i <= original.length; i ++){ | ||
| if (i !== value){ | ||
| value += original[i] | ||
| } | ||
| } | ||
| return orginal; | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
||
| reverse(original){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Close, but returns a string (-3) |
||
| let array = [] | ||
| for(let i = original.length - 1; i >= 0; i--){ | ||
| array += original[i] | ||
| } | ||
| return array | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
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.
There is no
elsecase here, your solution does not return if it is empty (-3)