Created
April 24, 2021 15:21
-
-
Save RuanAragao/66c1e81828c6b81ba1ffd8e73c349a49 to your computer and use it in GitHub Desktop.
Simple Transfer
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
let account = { | |
10000: { | |
name: 'CENTRALBANK', | |
sold: 1000.000 | |
}, | |
10100: { | |
name: 'RUAN ARAGÃO', | |
sold: 0.000 | |
}, | |
10101: { | |
name: 'CARLOS SOUSA', | |
sold: 0.000 | |
} | |
} | |
function transition(origin, destination, mount) { | |
const origin_number = origin; | |
const destination_number = destination; | |
origin = account[origin]; | |
destination = account[destination]; | |
if (typeof origin != "undefined" && typeof destination != "undefined") { | |
if (origin.sold >= mount) { | |
origin.sold = origin.sold - mount; | |
destination.sold = destination.sold + mount; | |
const ticket = ` | |
\$ CENTRAL BANK \$ | |
---------------------- | |
CLIENTE: ${origin.name} | |
CONTA: ${origin_number} | |
====================== | |
** TRANSFERIDO PARA ** | |
CLIENTE: ${destination.name} | |
CONTA: ${destination_number} | |
VALOR: R$ ${mount} | |
`; | |
console.log(ticket); | |
return true; | |
} | |
console.log('sold insufficient'); | |
return false; | |
} | |
console.log('accounts not exists'); | |
return false; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment