Skip to content

Instantly share code, notes, and snippets.

@simbld
Created October 12, 2024 08:17
Show Gist options
  • Save simbld/ddec6b7eb02aae35ef0f64f7918c7f2b to your computer and use it in GitHub Desktop.
Save simbld/ddec6b7eb02aae35ef0f64f7918c7f2b to your computer and use it in GitHub Desktop.
import assert from 'assert';
class BankCustomer {
constructor(name, pin) {
this.name = name;
this.pin = pin;
}
getName() {
return this.name;
}
verifyPinInput(input) {
return input === this.pin;
}
}
const customer = new BankCustomer('John Doe', 3579);
assert.equal(typeof customer.getName, 'function');
assert.equal(typeof customer.verifyPinInput, 'function');
assert.equal(customer.getName(), 'John Doe');
assert.ok(customer.verifyPinInput(3579));
console.log('test passed');
import assert from 'assert';
class BankCustomer {
private name: string;
private pin: number;
constructor(name: string, pin: number) {
this.name = name;
this.pin = pin;
}
getName(): string {
return this.name;
}
verifyPinInput(input: number): boolean {
return input === this.pin;
}
}
const customer = new BankCustomer('John Doe', 3579);
assert.equal(typeof customer.getName, 'function');
assert.equal(typeof customer.verifyPinInput, 'function');
assert.equal(customer.getName(), 'John Doe');
assert.ok(customer.verifyPinInput(3579));
> [email protected] start
> node dist/bankCustomer.js
test passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment