Skip to content

Instantly share code, notes, and snippets.

View Chesare22's full-sized avatar
🌳
Learning and coding λ

César González Chesare22

🌳
Learning and coding λ
  • Mérida, México
View GitHub Profile
const getCombinations = (availableNumbers = [], length = 0) => {
if(length === 0) {
return []
}
if(availableNumbers.length < length) {
return []
}
if(length === 1) {
const numbers = [5, 8, 1, 0, 10, -4];
// Tanto usingFunction como usingArrow resultan en [5, 8, 10]
const usingFunction = numbers.filter(function(number){
return number > 3;
});
const usingArrow = numbers.filter(number => number > 3);
// Son equivalentes
(/* argumentos */) => { return valor }
(/* argumentos */) => valor
// Son equivalentes
(argumento) => { /* ... */ }
argumento => { /* ... */ }
// Función anónima
function(/* parámetros */) {
/* cuerpo */
}
// Función flecha
(/* parámetros */) => {
/* cuerpo */
}
'Bienvenido ' + nombre + ', son las ' + (new Date().getHours() + 1) + ' horas';
`Bienvenido ${nombre}, son las ${new Date().getHours() + 1} horas`;