This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Инициализируем массив-результат, в который запишутся все значения. | |
Итерируем (проходим) по основному массиву и проверяем текущий элемент. | |
Если текущий элемент — не массив, то добавляем его в массив-результат и идём дальше. | |
Если текущий элемент — массив, то начинаем вложенный цикл, внутри которого идём по массиву и добавляем каждый его элемент в массив-результат. | |
Возвращаем массив-результат. | |
*/ | |
const flatten = (coll) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const userNames = ['petya', 'vasya', 'evgeny']; | |
const result = []; | |
for (const name of userNames) { | |
if (name === 'vasya') { | |
continue | |
; | |
} | |
result.push(name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
</head> | |
<body> | |
<div id="result"> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export default class Increment extends React.Component { | |
static defaultProps = { | |
count: 0, | |
}; | |
render() { | |
const { count } = this.props; | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sumPrimes(num) { | |
var count = [] | |
for(var j = 0; j < num; j++) { | |
if(isPrime(j)) { | |
count.push(j) | |
console.log(count) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}); |
NewerOlder