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");
@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