3

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.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
somejkuser
  • 8,856
  • 20
  • 64
  • 130

1 Answers1

1

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

Philipp
  • 15,377
  • 4
  • 35
  • 52