Yashotantra Academy
AI · Blockchain · Cloud · Data
Dark mode active
Learn
Tracks
ABCD
Certification
More
▾
Dark mode active
Learn
Tracks
ABCD
Certification
Study
Theory
Code Lab
Build
Solidity IDE
Staking Sandbox
Simulation
Reference
Wallets
Gas Fees
Explorers
← Code Lab
JavaScript
0/50 solved · 0%
All lessons
lesson
code
Objects · medium
22. Objects with methods
`this` inside object literals.
Create `const wallet = { balance: 10, add(n) { ... } }` where `add` increases `this.balance` and returns it.
Required in your answer:
this.balance
Reveal solution
Run & check
Reset
Runs in a sandboxed worker
const wallet = { balance: 10, // TODO add(n) };
Output appears here.
← 21. Closures
23. Classes →