JSFiddle - React, Tailwind, and code Playground

by deepak sisodiya

JavaScript

var alert  = function (str) {
   var st = document.createTextNode(str);
   var p = document.createElement('p');
   p.appendChild(st);
   document.querySelector('body').appendChild(p);
}

var person = function(full_name,age) {
    this.full_name = full_name;
    this.age = age;
}

person.prototype = {
    drive : function() {
        if(this.age >= 18) {
            alert(this.full_name + " is driving car")
        }else {
            alert(this.full_name + " is not eligible for driving car")
        }
        return this
    },
    eat: function() {
        alert(this.full_name + " is eating")
        return this
    }
}

var chotu = new person("harsh",7);
chotu.eat().drive();