Reputation: 125
I want to "refresh" parts of a website. I want to make a function where all of the parts will be refreshed except for those passed in the parameters. I am using a splat for the parameter, but I am stuck after that. Here is the code so far:
refresh = (exceptions...) ->
$("#playersTotalHealth").text("Health: #{player.totalHealth}")
$("#playersHealth").text("Your Health: #{player.currentHealth}/#{player.totalHealth}")
$("#opponentsHealth").text("Enemy's Health: #{e1.currentHealth}/#{e1.Health}")
...
If I only wanted to refresh #playersTotalHealth
then how can I use exceptions...
to do that?
Upvotes: 0
Views: 38
Reputation: 12129
This is more like a problem with the execution logic itself... You can just check if an item is present in the exceptions
array:
# Not in the exceptions array, execute...
if "#playersTotalHealth" not in exceptions then $("#playersTotalHealth").text "Health: #{player.totalHealth}"
Upvotes: 2