Skip to content

Instantly share code, notes, and snippets.

@samlucax
Created March 17, 2021 05:45
Show Gist options
  • Save samlucax/a3b0b1fb258e7e3f7f6d38daea6ca7c5 to your computer and use it in GitHub Desktop.
Save samlucax/a3b0b1fb258e7e3f7f6d38daea6ca7c5 to your computer and use it in GitHub Desktop.
Semana Agilizei 3.0 - Arquivo de funções úteis
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