Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Loops and Arrays (03_removeFromArray): Add vanilla/low-level nested loop solution

Aberta Para iniciantes
#696 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
1/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
75/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
javascript
Domínio
content

Direção de pesquisa

Comece pelo arquivo de soluções do exercício 03_removeFromArray, que já contém as soluções com forEach + includes e filter + includes, e pela suíte de testes desse exercício. Decida se a versão com laços aninhados entra como alternativa comentada ou como primeira solução e, depois, verifique se os testes existentes passam. Está concluído quando a nova solução estiver presente, com comentários explicativos sobre a flag de skip e o laço interno, e os testes de 03_removeFromArray continuarem passando.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Status: Needs Review
Prerequisites
  • I have thoroughly read and understand The Odin Project Contributing Guide
  • I have searched the existing issues to ensure this improvement hasn't been suggested before (please have a look through our open issues list to make sure)
  • The title of this issue follows the <Location of the improvement>: <Brief description of the improvement> format, e.g. Exercises: Add exercise on XYZ
  • (Optional) I am interested in working on this issue and would like to be assigned to it
Improvement Description

I would like to propose adding a third, "vanilla/low-level" solution to the 03_removeFromArray exercise.
Currently, the file provides two solutions: one using .forEach() + .includes(), and a more advanced one using .filter() + .includes(). While these are great, both rely on high-level built-in methods (.includes).
Adding an imperative solution using nested loops and a flag would be highly beneficial for beginners. It demonstrates how array filtering works "under the hood" at a foundational level using only basic language constructs (for...of, conditions, and flags) without relying on any built-in lookup methods.

Acceptance Criteria

• Add the nested loops solution as an alternative commented-out approach or as the initial basic approach in the solutions file.
• Ensure the solution passes all existing test suites for 03_removeFromArray.
• Provide clear code comments explaining the algorithmic logic (e.g., the purpose of the skip flag and the inner loop breakdown).

(Optional) Additional Comments

Here is the proposed implementation for the additional solution:

const removeFromArray = function (arr, ...toDelete) {
  const deletedArr = [];
  
  for (const elementArr of arr) {
    let skip = false;

    // Manually checking for inclusion without using .includes()
    for (const elementDelete of toDelete) {
      if (elementArr === elementDelete) {
        skip = true;
        break; // Stop looking if a match is found
      }
    }

    // Only push if the element was not flagged for deletion
    if (!skip) deletedArr.push(elementArr);
  }
  
  return deletedArr;
};

Use code with caution.
This approach helps students strengthen their algorithmic thinking and mental models before they fully transition to abstract methods like .filter().

Linguagem predominante
JavaScript
Estrelas
1.7k
Forks
48.9k
Merge médio
10h 11min
PRs com merge (30d)
6

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Issues semelhantes

Mais issues de JavaScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.