JSFiddle - React, Tailwind, and code Playground

by alirokni

HTML

<div id="one"></div>
<div id="two"></div>

JavaScript

var house = {
    hasDoor: true,
    hasWindows: true,
    hasCheminy: true,
    hasInternet: false
};

function House(door, window, cheminy, internet) {
    this.hasDoor = door;
    this.hasWindows = window;
    this.hasCheminy = cheminy;
    this.hasInternet = internet;
}

House.prototype.displayItems = function () {
    document.getElementById("one").innerHTML = "+Door: " + this.hasDoor + "\nWindows:" + this.hasWindows + "\nCheminy:" + this.hasCheminy + "\nInternet:" + this.hasInternet;
};

house.displayItems = function () {
    document.getElementById("two").innerHTML = "-Door: " + this.hasDoor + "\nWindows:" + this.hasWindows + "\nCheminy:" + this.hasCheminy + "\nInternet:" + this.hasInternet;
};

var myHouse = Object.create(house);
myHouse.hasCheminy = false;
myHouse.hasDoor = false;
myHouse.hasWindows = true;
myHouse.hasInternet = false;

var myNewHouse = Object.create(House.prototype, {
    hasCheminy: {
        writable: true,
        configurable: true,
        value: false
    },
    hasDoor: {
        writable: false,
        configurable: true,
        value: true
    },
    hasWindows: {
        writable: true,
        configurable: true,
        value: true
    },
    hasInternet: {
        writable: false,
        configurable: true,
        value: false
    }

});

myHouse.displayItems();
myNewHouse.displayItems();