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

feat:linked list add new method

Aperta
#832 0 commenti 5 reazioni 0 assegnatari Vedi su GitHub

@Shiva953 ci sta già lavorando.

Dal 20/4/2023.

  • #1032 di @Shiva953 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
data

Direzione di ricerca

The issue names no implementation file or test. Locate the linked-list implementation and its existing traversal-related tests, then review how iteration is currently exposed. Done means the linked list supports the proposed iterator and for-of traversal, with behavior verified for populated and empty lists.

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

Descrizione

traverse linked list is easy but uninteresting. You must add new variable and use while.So why not add a method to return a iterator.Then we can use for of to traverse. eg:

getIterator() {
    const _this = this
    return {
      *[Symbol.iterator]() {
        let currentNode = _this.head
        if (!currentNode) yield node
        while (currentNode) {
          yield currentNode.value
          currentNode = currentNode.next
        }
      }
    }
  }

use

const iter = linkedList.getIterator()
for(const item of iter){
 console.log(item)
} 
Lingua principale
JavaScript
Stelle
197k
Fork
31k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

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.

Altre issue di trekhleb/javascript-algorithms

Tutte le issue di trekhleb/javascript-algorithms

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.