| 📦 Turbo JS | 1 | /** Greets one person, several times over. */ |
| 2 | export class Greeter { | |
| 3 | #name; | |
| 4 | ||
| 5 | constructor(name) { | |
| 6 | this.#name = name; | |
| 7 | } | |
| 8 | ||
| 9 | /** Prints the greeting `times` times and says whether the name is capitalised. */ | |
| 10 | greet(times = 1) { | |
| 11 | const pattern = /^[A-Z]/; | |
| 12 | for (let i = 1; i <= times; i++) { | |
| 13 | console.log(`Hello, ${this.#name}! (${i})`); | |
| 14 | } | |
| 15 | return pattern.test(this.#name); | |
| 16 | } | |
| 17 | } |