@crsimpson5
Posted
Hey, Halibal.
One simple change would be to consolidate your calculatep5, calculatep10, etc. functions into one function, since they all do the same thing. You can define a parameter for the percentage, and then replace the hard-coded number in your function with the variable.
function calculatep(percentage) {
...
let tip = billP / percentage /NoPP
...
}
And call the function like so: calculatep(15)
I recently completed this challenge, so you can check out my code if you'd like.
Marked as helpful
@halibal
Posted
@crsimpson5 Thanks Curtis, This helped a lot! Changed the code the way as you explained above, it works fine and it is definitely shorter now :)