JSFiddle - React, Tailwind, and code Playground

by tchalvakspam

JavaScript

function capitalize (text) {
    return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
}

var apple = {
    type: "macintosh",
    color: "red",
    cost: 5,
    markup: 1.5,
    getInfo: function () {
        return this.color + ' ' + this.type + ' apple';
    },
    getPrice: function(){
        return this.cost * this.markup;
    }
};
var person = {
    birthdate: '8/30/1980',
    firstname: 'leeroy',
    middleinitial: 'b',
    lastname: 'jenkins',
    getAge: function () {
        return -(new Date() - new Date(this.birthdate));
    },
    getFullFormattedName: function () {
        return capitalize(this.firstname+' '+this.middleinitial+' '+this.lastname);
    }
};


        
alert(person.getAge()+' '+person.getFullFormattedName());
alert(apple.getInfo()+' '+apple.getPrice());