JSFiddle - React, Tailwind, and code Playground

by Ryan Brown

JavaScript

//output will be in console

//define the class
var example = function(){
    this.person = function(name) {
        name = "I am " + name;
        console.log(name);
        return this;
    }
    
    this.age = function(age) {
        age = "My age is " + age;
        console.log(age);
        return this;
    }
    
    this.faveColor = function(color) {
        color = "My favorite color is " + color;
        console.log(color);
        return this;
    }
    
    this.faveBrand = function(brand) {
        brand = "My favorite brand is " + brand;
        console.log(brand);
        return this;
    }
    
    this.favePlace = function(place) {
        place = "My favorite place is " + place + ".";
        console.log(place);
        return this;
    }
}


//create new object that inherits all methods
seeIt = new example(); 
//method chain
seeIt.person("Travis").age("33").faveColor("blue").faveBrand("Nike").favePlace("the lake");