Created
March 17, 2021 05:45
-
-
Save samlucax/a3b0b1fb258e7e3f7f6d38daea6ca7c5 to your computer and use it in GitHub Desktop.
Semana Agilizei 3.0 - Arquivo de funções úteis
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
export const format = (value) => { | |
let formattedValue | |
formattedValue = value.replace(',', '.') | |
formattedValue = Number(formattedValue.split('$')[1].trim()) | |
formattedValue = String(value).includes('-') ? -formattedValue : formattedValue | |
return formattedValue | |
} | |
export const randomNumber = () => { | |
return Math.floor(Math.random() * 101) | |
} | |
export const prepareLocalStorage = (win) => { | |
win.localStorage.setItem('dev.finances:transactions', JSON.stringify([ | |
{ | |
description: "Mesada", | |
amount: randomNumber() * 100, | |
date: "11/03/2021" | |
}, | |
{ | |
description: 'Suco Kapo', | |
amount: - (randomNumber() * 100), | |
date: "12/03/2021" | |
} | |
]) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment