Draft

Breadth-First DOM Traversal

Description:

In this web-based twist on a classic computer science problem, you'll traverse a set of dom-like objects.

The goal is to traverse them "breadth first", so if you have domish nodes that look like this:

         a
        / \
       b   c
      /
     d

You should traverse them in order a b c d, not a b d c.

The structure of these objects is very simple, and similar to a DOM node on a webpage:

let h1 = Node('h1')
let p = Node('p')
let article = Node('article', [h1, p])
article.tagName;      // 'article'
article.children;     // [h1, p]
article.firstChild;   // h1
h1.children;          // []
h1.firstChild;        // undefined

You shouldn't need to use the construction API but I include it here for completeness.

Algorithms

More By Author:

Check out these other kata created by SimplGy

Stats:

CreatedOct 5, 2016
Warriors Trained129
Total Skips32
Total Code Submissions169
Total Times Completed24
JavaScript Completions24
Total Stars3
% of votes with a positive feedback rating67% of 12
Total "Very Satisfied" Votes7
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes3
Total Rank Assessments13
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • SimplGy Avatar
Ad