JSFiddle - React, Tailwind, and code Playground
by Ryan Brown
JavaScript
//output will be to HTML
//define the class
var example = function(){
this.log = '';
this.person = function(name) {
name = "I am " + name;
this.log += name + ". ";
return this;
}
this.age = function(age) {
age = "My age is " + age;
this.log += age + ". ";
return this;
}
this.faveColor = function(color) {
color = "My favorite color is " + color;
this.log += color + ". ";
return this;
}
this.faveBrand = function(brand) {
brand = "My favorite brand is " + brand;
this.log += brand + ". ";
return this;
}
this.favePlace = function(place) {
place = "My favorite place is " + place + ".";
this.log += place;
return this;
}
}
//create new object that inherits all methods
seeIt = new example();
//method chain
document.getElementById("test").innerHTML = seeIt.person("Ryan").age("23").faveColor("blue").faveBrand("Nike").favePlace("Wherethetreeis").log;