Загрузка данных


https://yandex.ru/search/?text=linter+drk.xbnm&lr=2&clid=5988311-105&win=724


const  house = {
    houseNum: "12c",
    street: "first",
    countOfPeople: 250,
    info() {
        console.log(`House number: ${this.houseNum}, street: ${this.street}, count of people: ${this.countOfPeople}`);
    }
}

house.info()

const door = {};
door.color = "brown";
door.material = "wood";
door.width = 100;
door.height = 120;

function changeWidth (door, newWidth) {
    if (newWidth <= door.width) {
        console.log(`New width ${newWidth} is less than current width ${door.width}. Width not changed.`);
        return
    } else {
        door.width = newWidth;
    }   
}

changeWidth(door, 110);
console.log(`New width of the door is: ${door.width}`);

function changeHeight (door, newHeight=door.width) {   //=по умолчанию или сразу значение, если бы не было проверки при return
    if (newHeight <= door.height) {
        console.log(`New height ${newHeight} is less than current height ${door.height}. Height not changed.`);
        return
    } else {
        door.height = newHeight;
    }
}

changeHeight(door, 130);
console.log(`New height of the door is: ${door.height}`);


const colors =["red", "blue", "green", "yellow", "black", "white"];
const suitCaseDTO = new Object();

function initializeSuitCase (suitCaseDTO) {
    let randomIndex = Math.floor(Math.random() * colors.length);    ////random заходим с ограничением color.lenght
    let randomWidth = Math.floor(Math.random() * (400 - 100 + 1)) + 100;
    let randomHeight = Math.floor(Math.random() * (randomWidth * 3)) + 100;
    suitCaseDTO.color = colors[randomIndex];
    suitCaseDTO.width = randomWidth;
    suitCaseDTO.height = randomHeight;
}

initializeSuitCase(suitCaseDTO);

console.log(suitCaseDTO);



// ________Classes________

const personObject  = {
    name: "John",
    age: 30
}

class Person {
    constructor(name, age, status, asideInfo) {  // то, что написано в конструкторе, будет выполняться при создании нового объекта класса
        this.name = name;
        this.age = age;   //undefined, или значение по умолчанию = 15
        this.status = status;
        this.asideInfo = asideInfo;
    }
    greet() {   //срабатывает только при вызове. не самостоятельно, в классе может быть дохрена функций 
        console.log(`Hello, my name is ${this.name} and I am ${this.age} years old.`);
    }
}


// console.log(badPerson.name);
// badPerson.greet();
// console.log(goodPerson.name);
// goodPerson.greet();

// personObject.name = "Jane";
// personObject.age = 25;

class AsideInfo {
    constructor(sex, marks) {
        this.sex = sex;
        this.marks = marks;
    }
}

const asideInfobad = new AsideInfo("male", [5, 4, 3, 5, 4]);
const asideInfoGood = new AsideInfo("female", [5, 5, 5, 4, 5]);
const badPerson = new Person("Bad John", 40, "bad", asideInfobad);
const goodPerson = new Person("Good Jane", 30, "good", asideInfoGood);

console.log(badPerson.asideInfo.marks);