Advertisement
Spocoman

02. Distinct Array

Feb 6th, 2022
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function distinctArray(arr) {
  2.     for (let i = 0; i < arr.length; i++){
  3.         for (let j = i + 1; j < arr.length; j++){
  4.             if (arr[i] === arr[j]){
  5.                 arr.splice(j, 1);
  6.                 j--;
  7.             }
  8.         }
  9.     }
  10.     console.log(arr.join(' '));
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement