class JS

Run Settings
LanguageJavaScript
Language Version
Run Command
class BankAccount { constructor(name, accountNumber, balance) { this.name = name; this.accountNumber = accountNumber; this.balance = balance; } deposit(amount) { if (amount > 0) { this.balance += amount; } else { console.log("Deposit amount must be positive."); } } withdraw(amount) { if (amount <= this.balance) { this.balance -= amount; } else { console.log("Insufficient funds for this withdrawal."); } } getBalance() { return this.balance; } getAccountDetails() { return "Account Holder: " +this.name; } } // Example usage: // const account = new BankAccount("YUSUPH MDOE", "40052258006", 1500.0); // account.deposit(-200.0); // console.log(account.getBalance()); // account.withdraw(10000.0); // console.log(account.getBalance()); // console.log(account.getAccountDetails());
class Person{ constructor(name,age){ this.name = name; this.age = age; } greet(){ return "Greetings"; } } class Student extends Person{ constructor(name,age,course){ super(name,age); this.course = course; } study(){ return this.name +" is studying "+ this.course; } } const w = new Student("Amina", 27, "Javescript") console.log(w.study());
Editor Settings
Theme
Key bindings
Full width
Lines