JSFiddle - React, Tailwind, and code Playground

HTML

<div>
  <fieldset>
    <legend>Module Pattern</legend>
      <p id ="foo"></p>
      <p id ="fooo"></p>
   </fieldset> 
</div>

JavaScript

//simple foo, just like the example in question but using module pattern
var foo = function() {
  var that = {};
  
  that.a = 7;
  that.b = 6;
  
  that.c = function() {
    return that.a + that.b;
  }
  
  return that;
};
var fooObject = foo();
$('#foo').text('C Value: ' + fooObject.c());

fooObject.a = 3
fooObject.b = 7;
$('#fooo').text('C Value: ' + fooObject.c());