Loops and Arrays (03_removeFromArray): Add vanilla/low-level nested loop solution
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
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
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Issues semelhantes
-
Four problem loader browser tests fail on WindowsTalvez já em andamento @Patriciaath999 assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
juice-shop/juice-shop#3686 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
TheOdinProject/curriculum#31465 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
TurboDocx/html-to-docx#254 ·
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia