Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

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

未關閉 適合新手
#696 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
1/5
預估耗時
1-3 小時
新手友好度
75/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
javascript
領域
content

研究方向

從 03_removeFromArray 練習的解答檔案開始,該檔案已經包含 forEach + includes 和 filter + includes 兩種解法,以及該練習的測試套件。決定巢狀迴圈版本是要以註解掉的替代方案加入,還是作為第一個解法加入,然後檢查現有測試是否通過。完成的標準是:新解法已加入,並對 skip 旗標和內層迴圈加上說明性註解,且 03_removeFromArray 的測試仍然全部通過。

由索引模型根據 Issue 內容生成。

描述

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

主要語言
JavaScript
星號
1.7k
分支
48.9k
平均合併
10 小時 11 分鐘
30 天內合併 PR
6

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。