我希望每个函数的输出产生$ x.xx,就像它是一个价格一样。不熟悉javascript有一个简单的方法可以实现这个目标,还是一个复杂的系统来获得我想要的项目结果?
以下是我在javascript中所做的代码:
//First function outputs a random number
var myFirstFunction = function(First)
{
return First;
};
var FirstAnswer = myFirstFunction(Math.random());
console.log(FirstAnswer);
//Second function outputs the random number multiplied by 10
var mySecondFunction = function(Second)
{
return Second * 10;
};
var SecondAnswer = mySecondFunction(FirstAnswer);
console.log(SecondAnswer);
//Third function divided the random number by 3.3
var myThirdFunction = function(Third)
{
return Third / 3.3;
}
var ThirdAnswer = myThirdFunction(SecondAnswer);
console.log(ThirdAnswer)