├── .gitignore ├── 1-Fundamentos.pdf ├── 2-Programacion-Funcional.pdf ├── 3-Programacion-Asincrona.pdf ├── README.md └── ejercicios └── e1-callbacks └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | */**/node_modules 2 | node_modules 3 | pruebas/*.* 4 | -------------------------------------------------------------------------------- /1-Fundamentos.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redradix-school/curso-javascript-pro/a715d12455714d0c84cce5e14c3e98fe2f7f7667/1-Fundamentos.pdf -------------------------------------------------------------------------------- /2-Programacion-Funcional.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redradix-school/curso-javascript-pro/a715d12455714d0c84cce5e14c3e98fe2f7f7667/2-Programacion-Funcional.pdf -------------------------------------------------------------------------------- /3-Programacion-Asincrona.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redradix-school/curso-javascript-pro/a715d12455714d0c84cce5e14c3e98fe2f7f7667/3-Programacion-Asincrona.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Material del curso de JavaScript Avanzado 2 | Más información en https://redradix.com/cursos/javascript-avanzado/ 3 | -------------------------------------------------------------------------------- /ejercicios/e1-callbacks/index.js: -------------------------------------------------------------------------------- 1 | const rand = n => Math.round(n * Math.random()); 2 | const coin = () => rand(2) > 1; 3 | const rarely = () => rand(10) > 7; 4 | 5 | function fail(test, reason) { 6 | return test() ? new Error(`Error: ${reason}`) : null; 7 | } 8 | 9 | function getPlayers(callback) { 10 | const players = ['Fry', 'Bender', 'Leela', 'Amy', 'Zoidberg']; 11 | setTimeout(() => callback(fail(coin, 'getPlayers'), players), 100); 12 | } 13 | 14 | function throwDice(callback) { 15 | setTimeout(() => callback(fail(rarely, 'throwDice'), 1 + rand(6)), 100); 16 | } 17 | 18 | const board = []; 19 | 20 | function savePlayerScore(score, callback) { 21 | setTimeout(() => { 22 | if (coin()) 23 | callback(new Error('Error: savePlayerScore')); 24 | else { 25 | board.push(score); 26 | callback(null); 27 | } 28 | }, 100); 29 | } 30 | 31 | function getScoreBoard(callback) { 32 | setTimeout(() => callback(fail(coin, 'getScoreBoard'), board), 100); 33 | } 34 | --------------------------------------------------------------------------------