FrontEnd.ro logo
Proprietăți Private

class CreditCard {
  #number;

  constructor() {
    this.#number = '...';
  }

  get #formattedNumber() {
    return this.#number.split('').join('-');
  }
  
  getInfo() {
    const lastFour = this.#formattedNumber.slice(-7);
    return `Last four numbers: ${lastFour}`;
  }
}