Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda