This exercise was a bit tricky. Figured I\'d post my solution to see if anyone did it differently or if there\'s anyone who knows a better way.
I\'m not sure on best pra
My microposts.js.coffee
uses the jQuery .css method to change the color of the characters remaining based on the value of the variable remaining
to more closely mirror the behavior of twitter
updateCountdown = ->
remaining = 140 - jQuery("#micropost_content").val().length
jQuery(".countdown").text remaining + " characters remaining"
jQuery(".countdown").css "color", (if (140 >= remaining >= 21) then "gray")
jQuery(".countdown").css "color", (if (21 > remaining >= 11) then "black")
jQuery(".countdown").css "color", (if (11 > remaining) then "red")
jQuery ->
updateCountdown()
$("#micropost_content").change updateCountdown
$("#micropost_content").keyup updateCountdown
Thanks to all who answered before.