Last active
March 11, 2017 09:48
-
-
Save yefremov/b8069e2f4c3f9cc57e1d53d5398c80de to your computer and use it in GitHub Desktop.
Revisions
-
yefremov revised this gist
Mar 11, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ // // https://www.youtube.com/watch?v=2jp8N6Ha7tY // -
yefremov revised this gist
Mar 11, 2017 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@ // // https://www.youtube.com/watch?v=2jp8N6Ha7tY // // Capitalize the first letter of a string, or all words in a string. function capitalize(str) { return str.charAt(0).toUpperCase() + str.substring(1); -
yefremov revised this gist
Mar 11, 2017 . No changes.There are no files selected for viewing
-
yefremov created this gist
Mar 11, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,69 @@ // Capitalize the first letter of a string, or all words in a string. function capitalize(str) { return str.charAt(0).toUpperCase() + str.substring(1); } // Arrays var protuguese = [ 'galinha', 'vaca', 'milho' ]; protuguese.map(capitalize); // => ["Galinha", "Vaca", "Milho"] // Tree var familyTree = { value: 'mattias', nodes: [ { value: 'eva', nodes: [ { value: 'ove' }, { value: 'sonja' }, ] }, { value: 'maths', nodes: [ { value: 'anna' }, { value: 'gustav' }, ] } ] }; function mapTree(node, mapper) { return { value: mapper(node.value), nodes: node.nodes ? node.nodes.map(function (node) { return mapTree(node, mapper); }) : null }; } mapTree(familyTree, capitalize); // => { // value: 'Mattias', // nodes: [ // { // value: 'Eva', // nodes: [ // { value: 'Ove' }, // { value: 'Sonja' }, // ] // }, // { // value: 'Maths', // nodes: [ // { value: 'Anna' }, // { value: 'Gustav' }, // ] // } // ] // };