Here is my PHP code:
$kg= 75.20283619791667;
$lbs = sprintf("%.1f",$kg*2.20462);
// $lbs should equal 165.8
What is the equivalent in JavaScript if I start with:
var kg=75.20283619791667;
var lbs=2.20462*kg;
And I want to end with 165.8 as in the PHP example.
There is no out of the box equivalent for sprintf in javascript. But there are already some libraries which implemented this function on their own. For example you could have a look at: https://github.com/alexei/sprintf.js
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