Skip to content

Simon Björkberg WDPT-MAR23 #3698

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
fixed iteration 5
  • Loading branch information
SimonBjorkberg committed Mar 28, 2023
commit 2ebe9220bd496a19fb32a40e9b9b8d5d09a13fe6
18 changes: 16 additions & 2 deletions src/functions-and-arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,22 @@ const wordsUnique = [
'bring'
];

function uniquifyArray() {}

function uniquifyArray(words) {
if (words.length === 0) {
return null;
}
let newArray = [];
for (let i = 0; i < words.length; i++) {
if (newArray.includes(words[i])) {
continue;
}
else {
newArray.push(words[i]);
}
}
return newArray;
}
uniquifyArray(wordsUnique)


// Iteration #6: Find elements
Expand Down