JSFiddle - React, Tailwind, and code Playground

by bobbyfrancisjoseph

HTML

<p id="demo"></p>
<button id="sujith" name="button" value="OK" type="button">Click Me</button>

JavaScript

function person(first, last, age, eye) {
  this.firstName = first;
  this.lastName = last;
  this.age = age;
  this.eyeColor = eye;
}
person.prototype.name = function() {
  return this.firstName + " " + this.lastName
};

var myFather = new person("John", "Doe", 50, "blue");
var myFriend = new person("Sujith", "Don", 50, "blue");


document.getElementById("demo").innerHTML =
  "My father is " + myFather.name();
  
sujith.onclick = function(){
    
  document.getElementById("demo").innerHTML =
  "My friend is " + myFriend.name() + ;
    
  }