class Delivery {
constructor(name, phone) {
this.name = name;
this.phone = phone;
this.validPhone = phone[0] === "+";
}
}
const name = "Pizza";
const phone = "81234567890";
const deliveryName = new Delivery(name, phone);
console.log(deliveryName.validPhone); // false
class Delivery {
constructor(name, phone) {
this.name = name;
this.phone = phone;
this.validPhone = phone.startsWith("+");
}
}
const delivery = new Delivery("Pizza", "81234567890");
console.log(delivery.validPhone); // outputs: false
Пример значений переменных:
name = "Pizza"
phone = "81234567890"
Пример результата:
false