Skip to content

Instantly share code, notes, and snippets.

View ecaepsey's full-sized avatar
🏠
Working from home

Damir Aushenov ecaepsey

🏠
Working from home
  • Keremet Bank
  • Kyrgyzstan
View GitHub Profile
/*
Инициализируем массив-результат, в который запишутся все значения.
Итерируем (проходим) по основному массиву и проверяем текущий элемент.
Если текущий элемент — не массив, то добавляем его в массив-результат и идём дальше.
Если текущий элемент — массив, то начинаем вложенный цикл, внутри которого идём по массиву и добавляем каждый его элемент в массив-результат.
Возвращаем массив-результат.
*/
const flatten = (coll) => {
@ecaepsey
ecaepsey / continue.js
Created April 20, 2020 19:00
continue example
const userNames = ['petya', 'vasya', 'evgeny'];
const result = [];
for (const name of userNames) {
if (name === 'vasya') {
continue
;
}
result.push(name);
@ecaepsey
ecaepsey / index.html
Created March 19, 2020 18:05
simpleApp
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="result">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@ecaepsey
ecaepsey / .js
Created March 28, 2019 05:14
react component
import React from 'react';
export default class Increment extends React.Component {
static defaultProps = {
count: 0,
};
render() {
const { count } = this.props;
return (
const findSum = (arr, val) => {
for (let i = 0; i < arr.length; i++) {
for (let j = 0; j < arr.length; j++) {
if (i !== j && arr[i] + arr[j] === val) {
return true;
};
};
};
return false;
};
@ecaepsey
ecaepsey / .js
Created March 6, 2019 05:04
Format SUm
var input = 222323.34343;
function formatSum(sum) {
if(Number.isInteger(sum)) {
return sum
}
var beforeDot = /[^.]*/.exec(sum)[0]
var afterDot = /(?<=\.).*/.exec(sum)[0]
return beforeDot + ',' + afterDot
rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-* && watchman watch-del-all && rm -rf node_modules && yarn install && npm start -- --reset-cache
@ecaepsey
ecaepsey /  index.js
Created January 20, 2019 12:31
SUM OF PRIME
function sumPrimes(num) {
var count = []
for(var j = 0; j < num; j++) {
if(isPrime(j)) {
count.push(j)
console.log(count)
}
@ecaepsey
ecaepsey / index.js
Created June 30, 2018 15:11
sorting
m.sort(function (a, b) {
if (a === b) {
return 0;
}
if (typeof a === typeof b) {
return a < b ? -1 : 1;
}
return typeof a < typeof b ? -1 : 1;
});