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
  • 42,835
  • 20
  • 145
  • 262
somejkuser
  • 8,656
  • 19
  • 58
  • 122

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,257
  • 4
  • 29
  • 47