Skip to content

Instantly share code, notes, and snippets.

@LuisRBarreras
Last active January 2, 2016 18:59
Show Gist options
  • Save LuisRBarreras/8347012 to your computer and use it in GitHub Desktop.
Save LuisRBarreras/8347012 to your computer and use it in GitHub Desktop.
javascript module patter
//The module pattern
var feature = (function() {
var sidewaysTriangle = function(n) {
for(var i=0; i<n; i++)
{
var output = "";
for(var j=0; j<=i; j++)
{
output+="*";
}
console.log(output);
output = "";
}
for(var i=0; i<n; i++)
{
var output = "";
for(var j=n-1; j>i; j--)
{
output+="*";
}
console.log(output);
output = "";
}
};
//public API
return {
publicIsoceles: isoceles,
sidewaysTriangle: sidewaysTriangle
};
})();
feature.sidewaysTriangle(4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment