Skip to content

Instantly share code, notes, and snippets.

View andreyshedko's full-sized avatar
🇨🇿
Working from home

Andrey Shedko andreyshedko

🇨🇿
Working from home
  • Prague, Czech Republic
View GitHub Profile
@andreyshedko
andreyshedko / reversestring_1.js
Last active February 28, 2021 10:31
Reverse string
// Решение 1
function reverse(string) {
return string.split('').reverse().join('');
}
for (let character of string) {
reversed = character + reversed;
}
return reversed;
git commit --amend -m "Сообщение без ошибок"
const x = [[1,2,[3]],4];
const flat = (arr) => {
if (Array.isArray(arr)) {
return arr.reduce((prev,curr) => {
return prev.concat(flat(curr));
}, []);
} else {
return arr;
}
}
const array = [1, 2, 3, 5, 1, 5, 9, 1, 2, 8];
Array.from(new Set(array));
@andreyshedko
andreyshedko / gist:799e36ce096c7625aac720f82d74ec5d
Created June 19, 2018 08:45
Fill array with range of numbers
[...Array(10).keys()]
const {host, href, protocol} = window.location;
console.log(host);
console.log(href);
console.log(protocol);