Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#696 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript
Ambito
content

Direzione di ricerca

Inizia dal file delle soluzioni dell'esercizio 03_removeFromArray, che contiene già le soluzioni con forEach + includes e filter + includes, e dalla suite di test di quell'esercizio. Decidi se la versione con cicli annidati va inserita come alternativa commentata o come prima soluzione, quindi verifica che i test esistenti passino. È completato quando la nuova soluzione è presente con commenti esplicativi sul flag di skip e sul ciclo interno, e i test di 03_removeFromArray continuano a passare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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().

Lingua principale
JavaScript
Stelle
1.7k
Fork
48.9k
Merge medio
10h 11m
PR unite (30g)
6

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.