7

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.

2
  • 2
    Ehm, Jade is a template engine. Isn't Javascript the go-to tool here? Look here: jade-lang.com/reference/#code Jan 8, 2014 at 23:02
  • Yep, i know. But its also possible to calculate with Jade. So I thought that also goes round.
    – Vico
    Jan 8, 2014 at 23:13

2 Answers 2

8

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

7

.toFixed() may also be useful for showing 'clean' numbers: http://www.w3schools.com/jsref/jsref_tofixed.asp

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.