JSFiddle - React, Tailwind, and code Playground

by guyluchenbill

JavaScript

function Person(name,age) { 
    this.name = name; 
    this.age = age; 
}
Person.prototype = { 
    constructor: Person, 
    walk: function(speed) { 
        this.speed = speed; 
        return this.name + " can walk " + this.speed; 
    },
    talk: function() { 
        return this.name + " has been talking for " + this.age + " years."; 
    }
}; 

function Place(city, state) { 
    this.city = city; 
    this.state = state; 
}
Place.prototype = { 
    constructor: Place, 
    getCity: function() { 
        return this.city; 
    }, 
    setCity: function(city) { 
        this.city = city; 
        return this.city; 
    }, 
    getState: function() { 
        return this.state; 
    }, 
    setState: function(state) { 
        this.state = state; 
        return this.state; 
    }
}; 

var guy = new Person('guy', 27); 
var owosso = new Place('owosso','michigan'); 
console.log(owosso.getState()); 
owosso.setState('georgia');
console.log(owosso.getState());