Skip to content

Instantly share code, notes, and snippets.

@ghalimi
Created January 27, 2013 18:33
Show Gist options
  • Save ghalimi/4649641 to your computer and use it in GitHub Desktop.
Save ghalimi/4649641 to your computer and use it in GitHub Desktop.
SLN Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function SLN(cost, salvage, life) {
// Return error if any of the parameters is not a number
if (isNaN(cost) || isNaN(salvage) || isNaN(life)) return '#VALUE!';
// Return error if life equal to 0 (zero)
if (life === 0) return '#NUM!';
// Return straight-line depreciation
return (cost - salvage) / life;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment