Skip to content

Instantly share code, notes, and snippets.

@aareese
Created March 6, 2012 18:42
Show Gist options
  • Save aareese/1988107 to your computer and use it in GitHub Desktop.
Save aareese/1988107 to your computer and use it in GitHub Desktop.
First shot JS code for assigning company shares
function CompanyShares = {
var existingFlexShares : 70,
var existingFixedShares : 30,
var existingTotalShares : existingFixedShares + existingFlexShares,
getTotalShares: function (){
return existingTotalShares;
},
getFlexShares: function (){
return existingFlexShares;
},
getFixedShares: function (){
return existingFixedShares;
},
rewardAnnualShares: function (numSharesYear) {
existingFlexShares += numSharesYear;
existingFixedShares = Math.floor(existingFlexShares*3/7+1);
}
};
var numSharesYear = 0,
var reset = function (){
numSharesYear = 0;
};
function Person(name){
var shares = 0;
var shareAwardDate;
this.name = name;
this.awardShare = function (date){
shareAwardDate = date;
numSharesYear =+ Math.floor(shareAwardDate/365*10+1);
shares =+ Math.floor(shareAwardDate/365*10+1);
}
this.getShares = function(){
return shares;
}
};
function FounderShares = {
var sharesFounder : alyssa.getShares() + CompanyShares.getFixedShares() + 70,
getFounderShares: function () {
return sharesFounder;
}
};
var alyssa = new Person("Alyssa Reese");
var jesse = new Person("Jesse Seavers");
var melanie = new Person ("Melanie Gower");
@aareese
Copy link
Author

aareese commented Mar 6, 2012

Check it out. I decided to put my fledgling JS skills to test to write a little program for tracking & assigning company shares. The idea I had is something I'm thinking of doing for my UI/UX design firm, fleetCreature. There are 100 shares to begin with. I would own all of them to start: 30% as non-diminishable shares that I will always retain & 70% as diminishable shares that anyone working in the company can earn a percentage of. After the first year of their work, everyone is awarded 10 shares. Then for every year that someone works on the company following that, they are awarded 10 shares. If they work part of a year after the first year, they are awarded proportionally with the number rounded up to the nearest share. The program will be run once a year to award shares.

Pretty sure there's a lot of errors, etc but it was fun to write. Let me know what you think! Also, if anyone could give me a hint on what to use to test my JS, that would be awesome. RIght now I'm just writing it in Sublime Text 2 & am not sure how to actually run it in a console.

Cheers - Alyssa
http://fleetcreature.com

@focusaurus
Copy link

Check out http://visionmedia.github.com/mocha/ for testing. It works in the browser or node.js. Mocha is often paired with http://chaijs.com for the actual assertions in your tests. Don't worry about a console just yet. You can just make a test.html file with the right <script> tags and run your tests that way.

@brettgoulder
Copy link

If I were you...

I would run it through a syntax checker such as jshint.com

And I would test it at jsfiddle.net

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment