// Recursion

/*
 * When a function calls it self until it doesn't.
 */

let countDownFrom = (num) => {
    if (num === 0) {
        return;
    }
    console.log(num)
    countDownFrom(num - 1)
}

countDownFrom(10)
@@ -66,16 +66,24 @@
 t.%0A */%0A%0A
+// 1%0A// 
 let coun
@@ -105,16 +105,19 @@
 m) =%3E %7B%0A
+// 
     if (
@@ -129,16 +129,19 @@
 == 0) %7B%0A
+// 
         
@@ -152,14 +152,20 @@
 rn;%0A
+// 
     %7D%0A
+// 
     
@@ -181,20 +181,23 @@
 og(num)%0A
+//
     
+ 
 countDow
@@ -215,11 +215,17 @@
  1)%0A
-%7D%0A%0A
+// %7D%0A%0A// 
 coun
@@ -237,8 +237,677 @@
 From(10)
+%0A%0A// 2%0A%0Alet categories = %5B%0A    %7B id: 'animals', 'parent': null %7D,%0A    %7B id: 'mammals', 'parent': 'animals' %7D,%0A    %7B id: 'cats', 'parent': 'mammals' %7D,%0A    %7B id: 'dogs', 'parent': 'mammals' %7D,%0A    %7B id: 'chihuahua', 'parent': 'dogs' %7D,%0A    %7B id: 'labrador', 'parent': 'dogs' %7D,%0A    %7B id: 'persian', 'parent': 'cats' %7D,%0A    %7B id: 'siamese', 'parent': 'cats' %7D%0A%5D%0A%0Alet makeTree = (categories, parent) =%3E %7B%0A%0A    let node = %7B%7D%0A%0A    categories%0A        .filter(c =%3E c.parent === parent)%0A        .forEach(c =%3E node%5Bc.id%5D =%0A            makeTree(categories, c.id))%0A%0A    return node%0A%7D%0A%0Aconsole.log(%0A    JSON.stringify(%0A        makeTree(categories, null),%0A        null,%0A        2)%0A)

Make Tree Function