As the title suggests, I am looking for a way to round in Jade.
I have a variable that looks like this: 9.039444444444445.
Is it possible to output this number as: 9?
Thanks in advance for all those who support me.
Jade lets you run unbuffered JavaScript code in the templating engine. Assuming your variable is named number
- number = Math.round(number)
would round number
to the nearest integer as noted in the source at Robert Harvey's comment, the syntax is standard JavaScript as described here
.toFixed()
may also be useful for showing 'clean' numbers: http://www.w3schools.com/jsref/jsref_tofixed.asp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With