Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

211
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda