Finding correct tax bracket with iteration
Hello!
taxBracket
is finding the tax payed for each step of the tax bracket (stepOne, stepTwo
, etc ...)
What I want to do is find if myIncome
is:
--- higher than low and equal to high, if so, return the full sum
--- higher than low, but lower than high, if so subtract low from myIncome
and multiply with tax to find a new sum
--- lower than low, ignore the bracket
I'v tried all day with for loops, if...else statements, but I don't understand what to use to calculate all of those three conditions ...
5 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Yes! I totally understand that it's confusing ... 😅
Could I ask what is confusing, because I worry I will just write the same thing one more time, but slightly differently.
Is it my goal that is confusing?
This is a try to explain it in code ...
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Yes! As far as I understand it, the if... statements are doing what I want (love the first if, I obviously only need to check if it's the same ... 👍 )
So I added
myIncome
at the top, and it works, but it doesn't print anything even if there is a console.log in there. This is exzctly what I'm running:
I have to honest – I'm a newbie so even though I've gone through all of the stuff you put into this code, it is still a bit overwhelming. I need to sit down to really understand it.
Oh! I understood one mistake I did ... this is the exact code I'm running:
It returns this:
stepOne: undefined
stepTwo: undefined
stepThree: 992.94
stepFour: Income is to low for bracket
stepFive: Income is to low for bracket
stepOne and stepTwo should also have a number, specifically the sum of this function for each step:
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View