Loops and Arrays (03_removeFromArray): Add vanilla/low-level nested loop solution
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 1/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 75/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- javascript
- Domaine
- content
Piste de recherche
Commence par le fichier de solutions de l'exercice 03_removeFromArray, qui contient déjà les solutions forEach + includes et filter + includes, ainsi que la suite de tests de cet exercice. Décide si la version à boucles imbriquées est ajoutée comme alternative commentée ou comme première solution, puis vérifie que les tests existants passent. C'est terminé lorsque la nouvelle solution est présente avec des commentaires explicatifs sur le flag de skip et sur la boucle interne, et que les tests de 03_removeFromArray passent toujours.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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().
- Langage dominant
- JavaScript
- Étoiles
- 1.7k
- Forks
- 48.9k
- Merge moyen
- 10 h 11 min
- PR mergées (30 j)
- 6
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Issues similaires
-
Fixed-position outer <svg> lands outside a clip after scroll; fixed HTML boxes are re-anchoredOuverte🔧 in development
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
Add a "New blank resume" actionOuverteenhancement good first issue help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
-
p5.js 2.0+
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
processing/p5.js#9295 · 1 commentaire ·
Les mainteneurs répondent en général sous 3 jours
-
status: needs triage
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
mastra-ai/mastra#27210 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Add a "Talk title" columnOuvertecontent html
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100