Skip to content
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

Refactoring & Debugging Content #251

Merged
merged 24 commits into from
Nov 6, 2020
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
88a9338
Add sections for Debugging/Refactoring Module
bonham000 Nov 4, 2020
83e754e
Fix issue intializing monaco editor with custom type definitions
bonham000 Nov 4, 2020
ccbaa9b
Remove debug statements
bonham000 Nov 4, 2020
83966d6
Add the Debug the Sanitize Object Function Challenge
bonham000 Nov 4, 2020
58aeca7
Add the Debug the Reverse Iterator Challenge
bonham000 Nov 4, 2020
abf8631
Add the Debug the Truth Teller Challenge
bonham000 Nov 4, 2020
4c4b44e
Add the Debug the Tree Sum Problem Challenge
bonham000 Nov 4, 2020
901e50d
Add Working with Linked Lists Challenge
bonham000 Nov 4, 2020
a3241ec
Add Code Should be DRY Challenge
bonham000 Nov 4, 2020
040dc52
Add Variable Naming Conventions Challenge
bonham000 Nov 4, 2020
8db6336
Working on Refactor Some Poorly Written Code Challenge
bonham000 Nov 4, 2020
752d997
Delete refactoring challenge...
bonham000 Nov 4, 2020
dd51dcc
Add Refactoring Repeated Code in Tic Tac Toe Challenge
bonham000 Nov 5, 2020
311b287
Add Project: Refactor Legacy Project Code
bonham000 Nov 5, 2020
2cf7a66
Edit Intro challenge
bonham000 Nov 5, 2020
9e6b45a
Rename project
bonham000 Nov 5, 2020
af6d490
Rename Linked List Challenge
bonham000 Nov 6, 2020
7837bec
Update Debugging Section
bonham000 Nov 6, 2020
747d407
Fix bug in Debug the Truth Teller starter code
bonham000 Nov 6, 2020
0cb1c18
Edit
bonham000 Nov 6, 2020
b3ea686
Rename module
bonham000 Nov 6, 2020
ccb9f77
Add videos
bonham000 Nov 6, 2020
8befd83
Merge branch 'master' into content/debugging-and-refactoring
bonham000 Nov 6, 2020
afd1375
Merge branch 'master' into content/debugging-and-refactoring
bonham000 Nov 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add Working with Linked Lists Challenge
  • Loading branch information
bonham000 committed Nov 4, 2020
commit 901e50ddd6b8e340e31abdb360a0c3ae03cf002c
11 changes: 11 additions & 0 deletions packages/common/src/courses/01_fullstack_typescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -5060,6 +5060,17 @@
"solutionCode": "interface TreeNode {\n value: number;\n left: TreeNode | null;\n right: TreeNode | null;\n}\n\nconst treeSum = (tree: TreeNode): number => {\n let count = 0;\n\n // We have to count the current value in this tree node, of course...\n count += tree.value;\n\n if (tree.left !== null) {\n count += treeSum(tree.left);\n }\n\n if (tree.right !== null) {\n count += treeSum(tree.right);\n }\n\n return count;\n};\n",
"content": ""
},
{
"id": "yEly9kNYj",
"type": "typescript",
"title": "Working with Linked Lists",
"instructions": "A [linked list](https://en.wikipedia.org/wiki/Linked_list#:~:text=In%20computer%20science,%20a%20linked,which%20together%20represent%20a%20sequence.) is a data structure similar to an array, in which each item contains a reference to the next item. In the editor below there is a function `listToArray` which should take a linked list and reduce it to a plain array contain all of the `value`s in the linked list. But... there are some problems with the code as it is written currently\\!",
"testCode": "test(\"The `listToArray` function should be defined.\", () => {\n expect(typeof listToArray).toBe(\"function\");\n});\n\ntest(\"The `listToArray` function should be correctly reduce a linked list to an array of the list values.\", () => {\n class LL {\n value = null;\n next = null;\n constructor(value) {\n this.value = value;\n }\n }\n\n const list = new LL(100);\n const next = new LL(500);\n list.next = next;\n next.next = new LL(30);\n let expected = [100, 500, 30];\n let result = listToArray(list);\n expect(result).toEqual(expected);\n\n const a = new LL(1);\n const b = new LL(2);\n const c = new LL(3);\n const d = new LL(4);\n const e = new LL(5);\n const f = new LL(6);\n const g = new LL(7);\n const h = new LL(8);\n const i = new LL(9);\n a.next = b;\n b.next = c;\n c.next = d;\n d.next = e;\n e.next = f;\n f.next = g;\n g.next = h;\n h.next = i;\n\n result = listToArray(a);\n expected = [1, 2, 3, 4, 5, 6, 7, 8, 9];\n expect(result).toEqual(expected);\n\n expect(listToArray(null)).toEqual([]);\n expect(listToArray(new LL(0))).toEqual([0]);\n expect(listToArray(new LL(1001))).toEqual([1001]);\n});\n",
"videoUrl": "",
"starterCode": "interface List<T extends {}> {\n value: T;\n next: List<T> | null;\n}\n\nconst listToArray = (linkedList: List<any>): any[] => {\n const result = [];\n\n let current = linkedList.value;\n while (current.next !== null) {\n result.push(current.value);\n current = current.next;\n }\n\n return result;\n};\n",
"solutionCode": "interface List<T extends {}> {\n value: T;\n next: List<T> | null;\n}\n\nconst listToArray = (linkedList: List<any>): any[] => {\n const result = [];\n\n // Traversing linked lists can be tricky!\n let current: List<any> | null = linkedList;\n while (current !== null) {\n result.push(current.value);\n current = current.next;\n }\n\n return result;\n};\n",
"content": ""
},
{
"id": "C3aOJmAu3",
"type": "section",
Expand Down