Skip to content
Open
Changes from all 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
83 changes: 73 additions & 10 deletions ArrayUtils.js
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){
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is no else case here, your solution does not return if it is empty (-3)

if (array.length !== 0){
return false;
}
}

append(original, value){
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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;}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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;}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does not compile, from and to are indexed as arrays. from and to are numbers that represent a start and stop indices. (-11)

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){}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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;}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Close, Hint: indexOf([4,5,6,7,8,9,10], 6) should return 2 (-3)

indexOf(original, value){
for (let i = 0; i <= original.length; i ++){
if (i === value){
return i
}
}

}

reverse(original){}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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){
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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
}

}