Skip to content

Instantly share code, notes, and snippets.

View lantosgyuri's full-sized avatar

György Lantos lantosgyuri

  • AppLike
  • Hamburg, Germany
View GitHub Profile
const numbers = [1,2,3,4,5,5,4];
const uniqueItems = Array.from(new Set(numbers));
console.log(uniqueItems);
const createAdder = (base) => (secondary) => secondary + base;
const numbers = [1,2,3,4,5];
const fns = numbers.map(item => createAdder(item));
const pipe = (...fns) => x => fns.reduce((y, f) => f(y), x);
const addAll = pipe(...fns);
// console.log(addAll(6));
const arr = [1,2,3];
const arr2 = [4,5,6,[7], [8]];
console.log(arr.concat(arr2)); // not flattened
console.log([...arr, ...arr2]); // not flattened
console.log(arr.concat(...arr2)); // flattened
// This is not my code, I've just saved it for myself. Origin: https://github.com/leighhalliday/reduce-example
const people = [
{ id: "1", name: "Leigh", age: 35 },
{ id: "2", name: "Jenny", age: 30 },
{ id: "3", name: "Heather", age: 28 },
];
let result;
const array = [
1, 2, 3, 4,
];
const createAsyncfunction = number => new Promise((resolve, reject) => {
const tiemout = Math.floor(Math.random() * Math.floor(10));
if (number === 3) reject('Bad number');
else {
setTimeout(() => {
console.log('number is printed: ', number);