This file contains 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 characters
// underscore | |
_.pluck(dc, 'name') | |
// nativo | |
dc.map(x => x.name) | |
// output | |
// > ["batman", "superman", "greenarrow", "greenlantern"] |
This file contains 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 characters
// underscore | |
_.where(dc, { power: 70 }) | |
// nativo | |
dc.filter(x => x.power === 70) | |
// output | |
// > [ | |
// > Object { name: "greenarrow", power: 70 }, | |
// > Object { name: "greenlantern", power: 70 } | |
// > ] |
This file contains 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 characters
// undercore | |
_.findWhere(dc, { power: 90 }) | |
// nativo | |
dc.find(x => x.power === 90) | |
// output | |
// > Object { name: "superman", power: 90 } |
This file contains 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 characters
// underscore | |
_.contains([1, 2, 3], 3) | |
// nativo | |
[1, 2, 3].includes(3) | |
// output | |
// > true |
This file contains 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 characters
// underscore | |
_.max(dc, 'power') // quién será el héroe más poderoso? | |
// nativo | |
dc.reduce((x, y) => x.power > y.power ? x : y) | |
// output | |
// > Object { name: "batman", power: 100 } | |
// Lo siento Superman, Batman siempre gana! | |
// underscore | |
_.min(dc, 'power') // y el más flojo? |
This file contains 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 characters
// underscore | |
_.chain(dc).pluck('name').contains('greenarrow').value() | |
// nativo | |
dc.map(x => x.name).includes('greenarrow') | |
// output | |
// > true |
This file contains 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 characters
/* bling.js */ | |
window.$ = document.querySelectorAll.bind(document); | |
Node.prototype.on = window.on = function (name, fn) { | |
this.addEventListener(name, fn); | |
} | |
NodeList.prototype.__proto__ = Array.prototype; |
This file contains 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 characters
/* | |
* Task 1 | |
* Visible nodes in a node subtree | |
*/ | |
const solution = T => visibles(T, -100000) | |
const visibles = (T, max) => { | |
if (T === null) return 0 | |
let num = 0 |
This file contains 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 characters
// Array.prototype.includes() | |
[1, 2, 3].includes(2) // > true | |
[1, 2, 3].includes(4) // > false | |
// String.prototype.includes() | |
const str = 'Los gatos son seres superiores' | |
str.includes('gato') // > true | |
str.includes('perro') // > false |
This file contains 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 characters
7 ** 2 === Math.pow(7, 2) // > true | |
7 ** 3 === Math.pow(7, 3) // > true | |
2 ** 10 === Math.pow(2, 10) // > true |