JSFiddle - React, Tailwind, and code Playground

JavaScript

var CurrencyObject = function(Amount) {
    var money = Amount;
    return {
        toCents: function() {
            money *= 100;
            return money;
        },
        toDollars: function() {
            money /= 100;
            return money;
        },
        currentValue: money
    };
};


var c1 = CurrencyObject(1.99);
alert('cents = ' + c1.toCents() + '\ncurrent money = ' + c1.currentValue + '\ndollars = ' + c1.toDollars() + '\ncurrent money = ' + c1.currentValue);
var c2 = CurrencyObject(2.99);
alert('cents = ' + c2.toCents() + '\ncurrent money = ' + c2.currentValue + '\ndollars = ' + c2.toDollars() + '\ncurrent money = ' + c2.currentValue);
alert('cents = ' + c1.toCents() + '\ncurrent money = ' + c1.currentValue + '\ndollars = ' + c1.toDollars() + '\ncurrent money = ' + c1.currentValue);