In ClojureScript, how to display a float with 2 decimals?
clojurescript
Solution
(ns foo.bar
(:require
[goog.string :as gstring]
[goog.string.format]))
(.log js/console (gstring/format "%.2f" 1.2345))
Problem
I have tried to use `with-precision` but it didn't work: ``` (.log js/console (with-precision 2 1.2345)) ``` So I have used `toFixed`: ``` (.log js/console (.toFixed 1.2345 2)) ``` But I feel it's not the idiomatic way of doing that. In addition, I don't understand why `with-precision` doesn't work. Please inspire me...