Change account's money amount

Hello everyone.

I'm working on a game of chance code. There's a code about if player loses game, his/her money will transfer to the bank. And I'm doing this: if user lost, decrease amount of user and increase of amount of bank (user - x, bank + x).

Bank's amount increases, but user's amount doesn't decrease.

Here my code:

const FS = require ('fs')

const File = JSON.parse (FS.readFileSync ('./Data/Amounts.json', 'utf-8'))
var Amount = File []

File [] = Amount -= Y2
File.Bank = File.Bank += Number (Y2)
FS.writeFile ('./Data/Amounts.json', JSON.stringify (File), 'utf-8', Error_ => {
  if (Error_) throw Error_
1 Like

I’ve solved the problem. Thanks.


This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.