15 lines
464 B
TypeScript
15 lines
464 B
TypeScript
|
|
|
||
|
|
export function generatePrice(enteros: number, decimales: number) {
|
||
|
|
return (Math.floor(Math.random() * (10 ^ enteros)) / (10 ^ decimales)).toString()
|
||
|
|
}
|
||
|
|
|
||
|
|
export const CURRENCIES = ["USD", "EUR", "JPY"]
|
||
|
|
|
||
|
|
export function pickCurrencies(currencies: string[]) {
|
||
|
|
if (currencies.length == 1) return currencies[0]
|
||
|
|
const max = currencies.length
|
||
|
|
const min = 0
|
||
|
|
const select = Math.floor(Math.random() * (max - min)) + min
|
||
|
|
return currencies[select]
|
||
|
|
}
|