-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
162 additions
and
57 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Сделать так, чтобы у дробной части числа | ||
* минимальная длина соответствовала currencyObject.fractionalPartMinLength | ||
* @param {Array} numberArray - Число в виде массива ['-', '150', '/', '25']. | ||
* @param {Object} currencyObject - Объект с параметрами валюты. | ||
* @return {Array} Обновленный массив числа. | ||
*/ | ||
const fractionalPartToMinLength = (numberArray, currencyObject) => { | ||
// Если разделитель - дробная черта | ||
if (numberArray[2] === '/') { | ||
return numberArray; | ||
} | ||
const updatedNumberArray = [...numberArray]; | ||
// Если в дробной части цифр меньше, чем fractionalPartMinLength | ||
if (updatedNumberArray[3].length < currencyObject.fractionalPartMinLength) { | ||
// Заполнить нулями | ||
updatedNumberArray[3] = updatedNumberArray[3] + '0' | ||
.repeat(currencyObject.fractionalPartMinLength - updatedNumberArray[3].length); | ||
} | ||
return updatedNumberArray; | ||
}; | ||
|
||
export default fractionalPartToMinLength; |
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
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
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
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
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
Oops, something went wrong.