Skip to content

Instantly share code, notes, and snippets.

View piotrjaw's full-sized avatar

Piotr Jaworski piotrjaw

View GitHub Profile
const numbers = [2, 5, 8, 12, 33];
const result = numbers.reduce((result, currentNumber) => result + currentNumber, 0);
const numbers = [2, 5, 8, 12, 33];
let result = 0;
for (let i = 0; i < numbers.length; i++) {
result += numbers[i];
}
const flatten = (arr) => {
const result = [];
const _flatten = (arrayOrValue) => {
if (Array.isArray(arrayOrValue)) {
arrayOrValue.map(_flatten);
} else {
result.push(arrayOrValue);
}
};
@piotrjaw
piotrjaw / README.markdown
Created June 14, 2017 07:41 — forked from marijn/README.markdown
List of nationalities in YAML, CSV and TXT format

List of nationalities

It's time someone compiled a list of nationalities to use within a web application. This gist attempts to make a first move at that.

##List of countries

I've also compiled a list of countries

// Bonfire: Roman Numeral Converter
// Author: @piotrjaw
// Challenge: http://www.freecodecamp.com/challenges/bonfire-roman-numeral-converter?solution=function%20convert(num)%20%7B%0A%20%20var%20map%20%3D%20%5B%20%0A%20%20%20%20%5B1000%2C%20%27M%27%5D%2C%0A%20%20%20%20%5B900%2C%20%27CM%27%5D%2C%0A%20%20%20%20%5B500%2C%20%27D%27%5D%2C%0A%20%20%20%20%5B400%2C%20%27CD%27%5D%2C%0A%20%20%20%20%5B100%2C%20%27C%27%5D%2C%0A%20%20%20%20%5B90%2C%20%27XC%27%5D%2C%0A%20%20%20%20%5B50%2C%20%27L%27%5D%2C%0A%20%20%20%20%5B40%2C%20%27XL%27%5D%2C%0A%20%20%20%20%5B10%2C%20%27X%27%5D%2C%0A%20%20%20%20%5B9%2C%20%27IX%27%5D%2C%0A%20%20%20%20%5B5%2C%20%27V%27%5D%2C%0A%20%20%20%20%5B4%2C%20%27IV%27%5D%2C%0A%20%20%20%20%5B1%2C%20%27I%27%5D%0A%20%20%5D%3B%0A%20%20%0A%20if%20(num%20%3E%200)%20%7B%0A%20%20%20var%20i%20%3D%200%3B%0A%20%20%20while%20(num%20%2F%20map%5Bi%5D%5B0%5D%20%3C%201)%20%7B%0A%20%20%20%20%20i%2B%2B%3B%0A%20%20%20%7D%0A%20%20%20return%20map%5Bi%5D%5B1%5D%20%2B%20convert(num%20-%20map%5Bi%5D%5B0%5D)%3B%0A%20%7D%20els
@piotrjaw
piotrjaw / Jumping-dots-loader.markdown
Created March 27, 2015 11:06
Jumping dots loader