TGViewer
JavaScript JavaScript @javascript · 31.1K subscribers
Post #2830 3.93K
CHALLENGE

class Logger {
log(msg) {
return `[LOG]: ${msg}`;
}
}

class Formatter {
format(text) {
return text.toUpperCase();
}
}

class Service {
constructor(logger, formatter) {
this.logger = logger;
this.formatter = formatter;
}

process(data) {
const formatted = this.formatter.format(data);
return this.logger.log(formatted);
}
}

const service = new Service(new Logger(), new Formatter());
console.log(service.process('hello world'));
  • ❤ 4
  • 👍 3
  • 🤔 2
More from @javascript
  1. Sep 28, 2026Post #3524
  2. Sep 28, 2026CHALLENGE let order = []; function a() { try { return 'try'; } finally { order.push('a-fin…
  3. Sep 27, 2026Post #3522
  4. Sep 27, 2026CHALLENGE class Base { value = 10; getValue = () => this.value; constructor() { this.value…
  5. Sep 26, 2026Post #3520
  6. Sep 26, 2026CHALLENGE const obj = { value: 42, getValue() { return this?.value; }, getValueArrow: () =…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →