Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
I want to remove repetative elements of an array without using any in-built methods of javascript. When remove a then with a, A also to be removed
let RepeatingItemList = [3, 'a', 'a', 4, 3, 'b', 'A', 'b', 'c', 4, 6, 9, 8, 'b', 'a', 2, 6, 3];
let index = 0;
let compareIndex;
IndexLength = RepeatingItemList.length;
while (index < IndexLength) {
    compareIndex = index + 1;
    while (compareIndex < IndexLength) {
        if (RepeatingItemList[index] == RepeatingItemList[compareIndex]) {
            RepeatingItemList.splice(compareIndex, 1);

        }
        compareIndex++;
    }
    index++;
}
console.log(RepeatingItemList);
  1. Not to use any in-built methods of javascript.
  2. Remove A with all a.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could take an object for keeoing track of the seen items and normalize them before to a lower case string.

For removing unwanted items, you could use another variable for the new length of the array, which is the target for copy the item from the actual index to a closer position to start without unwanted items. At the end adjust the length of the array.

const
    remove = array => {
        const
            normalize = v => v.toString().toLowerCase(),
            seen = {};
            
        let l = 0,
            i = 0;        
        
        while (i < array.length) {
            if (!seen[normalize(array[i])]) array[l++] = array[i];
            seen[normalize(array[i])] = true;
            i++;
        }
        array.length = l;
    },
    array = [3, 'a', 'a', 4, 3, 'b', 'A', 'b', 'c', 4, 6, 9, 8, 'b', 'a', 2, 6, 3];
    
remove(array);
console.log(...array);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!