0

I’m using Rails 4.2.3. In my coffee script, I have

    console.log(hours) 
    hours = (hours < 10 ? "0" + hours : hours)
    console.log(hours)

but I’m getting some strange results. In the first line, console.log is printing out “14” (a number), but in the next console.log, it prints out “false”. I don’t understand why this is happening. It should remain “14”. What do I need to do to fix this?

Dave
  • 15,639
  • 133
  • 442
  • 830

1 Answers1

0

try :

hours = (hours < 10 ? "0" + hours.to_s : hours)
Boltz0r
  • 970
  • 5
  • 16
  • Doing that produces the error, "SyntaxError: [stdin]:32:48: unexpected :" when I load the page. Keep in mind htis is a coffee script, not a Ruby script. – Dave May 27 '16 at 19:09