Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
I don't know if the tests for this are broken or if I made a mistake, but something is wrong. The code I wrote inside a different text editor works great and gives me the expected years when I checked it against the test cases. However, when I run it through the codewars editor, the tests come back undefined. Can anyone help? Here's my code:
var years = 0;
function calculateYears(principal, interest, tax, desired) {
if(principal < desired){
var interestEarned = principal * interest;
var taxAmount = interestEarned * tax;
var net = interestEarned - taxAmount
principal += net;
years ++;
calculateYears(principal, interest, tax, desired)
}else{
return years
}
}