Skip to content
Open
Show file tree
Hide file tree
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
66 changes: 55 additions & 11 deletions ArrayUtils.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,65 @@
class ArrayUtils{
class ArrayUtils {

isEmpty(array){return false;}
constructor(original, array, 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.

No need for a constructor

this.original = original;
this.array = array;
this.value = value;
}

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.

isEmpty() does not work (-11)

if (array[""]) {
return false;
} else {
return true;
}
}

clone(original){return original;}
append(original, value) {
return original.push(value);
}

subArray(original, from, to){return original;}
getClone(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.

Solution works, make sure you don't change the function name though

clone = [...original];
return clone;
}

equals(arr1, arr2){return false;}
getSubArray(original, y, z) {
let subArray = original.slice(y, z + 1);
return subArray;
}

fill(original, value){}
arraysEqual(arr1, arr2) {
if (arr1 === arr2)
return true;
else if (arr1 == null || arr2 == null)
return false;
else(arr1.length !== arr2.length)
return false;
}

indexOf(original, value){return -1;}
fillArray(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.

indexOf() and remove() work, make sure you know how to do them manually as well

return original.fill(value);
}

remove(original, value){return original;}
indexOf(original, value) {
return original.indexOf(value);
}

reverse(original){}

remove(original, value) {
let copy = original;
for (let i = 0; i < copy.length; i++) {
if (copy[i] === value) {
newCopy += copy.splice(i, 1);
}
}
return newCopy;
}

reverseArray([original]) {
let newArray = [];
for (let i = original.length - 1; i >= 0; i--) {
newArray += original.charAt([i]);
}
return newArray;
}
}
17 changes: 17 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>

<head>
<title>Whaddup</title>
</head>

<body id="color">

<div id="remove"></div>


<script src="ArrayUtils.js"></script>

</body>

</html>