JSFiddle - React, Tailwind, and code Playground

JavaScript

function ElectricalNetwork(elements) {
    if (Array.isArray(elements)) {
        this.elements = elements;
    } else {
        throw new TypeError("elements must be an array");
    }
}


function Electrostation(power) {
    if (power >= 1 * Math.pow(10, 6) && power <= 100 * Math.pow(10, 6)) {
        this.power = power;
        this.nightpower = power;
    } else {
        throw new RangeError("power must be in range from 1 MW to 100 MW");
    }
}

Electrostation.prototype.getPower = function() {
    return this.power;
}

Electrostation.prototype.getPowerAtNight = function() {
    return this.nightpower;
}


function SolarPanele(power) {
    if (power >= 1 * Math.pow(10, 6) && power <= 5 * Math.pow(10, 6)) {
        this.power = power;
    } else {
        throw new RangeError("power must be in range from 1 MW to 5 MW")
    }
}

SolarPanele.prototype.nightpower = 0;

SolarPanele.prototype.getPower = function() {
    return this.power;
}

SolarPanele.prototype.getPowerAtNight = function() {
    return this.nightpower;
}


function someTypeOfSolarPanel() {
    this.power = 1 * Math.pow(10, 6);
}

someTypeOfSolarPanel.prototype = Object.create(SolarPanele.prototype);
someTypeOfSolarPanel.prototype.constructor = someTypeOfSolarPanel;


function anotherTypeOfSolarPanel() {
    this.power = 2 * Math.pow(10, 6);
}

anotherTypeOfSolarPanel.prototype = Object.create(SolarPanele.prototype);
anotherTypeOfSolarPanel.prototype.constructor = anotherTypeOfSolarPanel;


function House(apartments) {
    if (Array.isArray(apartments)) {
        if (apartments.length >= 1 || apartments.length <= 400) {
            this.apartments = apartments;
        } else {
            throw new RangeError("apartments count must be from 1 to 400");
        }
    } else {
        throw new TypeError("apartments must be an array");
    }

    this.power = 0;
    this.nightpower = 0;
}

House.prototype.getPower = function() {
    for (var apartment in apartments) {
        this.power +=...