We're revisiting an oldie but goodie, only this time using React! Here are your tasks:
- Pass a
nameproperty to eachAccountcomponent, one for "Checking", the other for "Savings"
- Use the property you set in
App.jsand add it to the<h2> - Add a
balanceproperty tostateand set to 0 initially - When the
Depositbutton is clicked, you should add the amount entered in the text field to the balance - When the
Withdrawbutton is clicked, you should deduct the amount entered in the text field to the balance
- You should not be able to withdraw more than the current balance
- If the current balance is 0, you should add a class of
zeroto the<div className="balance">div
Add the accounting package to format the balance.
- Remember to set a
refon the text field for targeting - The amount entered in the text field will initially be a string, so you'll need to convert that to a number
- Don't forget to
bindyour click methods!
All content is licensed under a CCBYNCSA 4.0 license. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact legal@ga.co.