Last active
February 26, 2020 10:47
-
-
Save sobchenyuk/9ac57d38eb80f1775f3728a5f960f5ec to your computer and use it in GitHub Desktop.
Helpers
This file contains hidden or 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
/** | |
* Получить процент из числа | |
*/ | |
getPercentage = ( value, max ) => ( value * 100 ) / max; | |
/** | |
* Возвращаем ближайшего числа в массиве | |
*/ | |
nearestNumberArray = ( arr, number ) => { | |
return arr.reduce( | |
(prev, curr) => Math.abs(curr - number) < Math.abs(prev - number) ? curr : prev | |
) | |
}; | |
/** | |
* Умножить число на процент | |
*/ | |
multiplyNumberPercentage = ( number, percent ) => ( number * percent ) / 100; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment