Keep calculator solution up to date if unit test was changed. #226
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Keep
calculator.js
andcalculator.spec.js
up to date, if previous pull request #223 08_calculator add some unit tests was approved.Need to add 1 line to
factorial()
andrecursiveFactorial()
solution, so they can pass all tests.All 28 tests passed.
![Screen Shot 2022-02-07 at 5 50 23 PM](https://user-images.githubusercontent.com/8423646/152907571-8a0842e5-37a4-419e-9222-10f178038000.png)
In the second commit Add an alternative power() solution, I add 1 more solution for
power()
.The old
power()
solution simply just call theMath.pow()
.I think the author is right. Considering that arguments can be any
float
number (ex:Math.pow(2, 2.5) = 5.65685424949238
), it's not that easy to write a real worldpower()
by ourself.But why not give them an alternative naive example. If we assume the arguments are integers, it's quite easy.
I keep the old
![Screen Shot 2022-02-07 at 9 41 23 PM](https://user-images.githubusercontent.com/8423646/152907859-f6893055-b508-4a58-b689-a9f4220882e4.png)
power()
as a main solution. The alternativeintPower()
is listed behind as a showcase. All 28 unit tests passed.