-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Develop #1758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Develop #1758
Changes from 8 commits
ca42dda
27217a2
f66f63d
a198be1
9104107
1304797
99329da
3549b95
eb8eae5
c5d87f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ master ] | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| node-version: [20.x] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| - run: npm install | ||
| - run: npm start & sleep 5 && npm test | ||
| - name: Upload tests report(cypress mochaawesome merged HTML report) | ||
| if: ${{ always() }} | ||
| uses: actions/upload-artifact@v2 | ||
| with: | ||
| name: report | ||
| path: reports |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,89 @@ const food = { | |
| const tree = document.querySelector('#tree'); | ||
|
|
||
| function createTree(element, data) { | ||
| // WRITE YOUR CODE HERE | ||
| for (const key in data) { | ||
| const firstList = document.createElement('li'); | ||
|
|
||
| firstList.textContent = key; | ||
|
|
||
| // element.append(firstList); | ||
| document.body.append(firstList); | ||
|
|
||
| const testLength = Object.keys(data[key]).length; | ||
|
|
||
| // console.log(testLength); | ||
|
|
||
| if (testLength > 0) { | ||
| const ul = document.createElement('ul'); | ||
|
|
||
| firstList.append(ul); | ||
|
|
||
| createTree(null, data[key]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The recursive call passes |
||
| } | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing |
||
| return element; | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The final tree is never appended to the |
||
| // if (tree) { | ||
| // createTree(tree, food); | ||
| // } | ||
|
|
||
| createTree(tree, food); | ||
|
|
||
| // ==== | ||
|
|
||
| // 'use strict'; | ||
|
|
||
| // const food = { | ||
| // Drink: { | ||
| // Wine: {}, | ||
| // Schnaps: {}, | ||
| // }, | ||
| // Fruit: { | ||
| // Red: { | ||
| // Cherry: {}, | ||
| // Strawberry: {}, | ||
| // }, | ||
| // Yellow: { | ||
| // Banana: {}, | ||
| // Pineapple: {}, | ||
| // }, | ||
| // }, | ||
| // }; | ||
|
|
||
| // const tree = document.querySelector('#tree'); | ||
|
|
||
| // function createTree(element, data) { | ||
| // // Твій основний цикл, який ти писав спочатку | ||
| // for (const key in data) { | ||
| // const firstList = document.createElement('li'); | ||
|
|
||
| // firstList.textContent = key; | ||
|
|
||
| // // Додаємо пункт у поточний список (element) | ||
| // element.append(firstList); | ||
|
|
||
| // // Перевіряємо, чи є вкладені елементи | ||
| // const test = Object.keys(data[key]).length; | ||
|
|
||
| // if (test > 0) { | ||
| // // Якщо є вкладеність, створюємо НОВИЙ список для цього рівня | ||
| // const nestedUl = document.createElement('ul'); | ||
|
|
||
| // // Додаємо цей список всередину нашого li | ||
| // firstList.append(nestedUl); | ||
|
|
||
| // // Викликаємо функцію знову для вкладеного списку | ||
| // // Це і є та сама рекурсія, яка замінює твій цикл "next" | ||
| // createTree(nestedUl, data[key]); | ||
| // } | ||
| // } | ||
| // } | ||
|
|
||
| // // Запускаємо один раз для головного контейнера | ||
| // // if (tree) { | ||
| // // createTree(tree, food); | ||
| // // } | ||
|
|
||
| // createTree(tree, food); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Items are appended to
document.bodyinstead of theelementparameter. The container should receive the tree structure, notdocument.body. Uncommentelement.append(firstList)and remove line 30.