Hi, Guys.
Who can help me with this puzzle?
There is a simple code, which I would like to simplify. Any idea?
And another issue, how can I get rid of “undefined” as a second value in console.
const price = 21000;
const sumAvailable = “1000”;
let sum;
const bitcoinAvailable = function(price, sumAvailable) {
if (typeof sumAvailable === “number” && sumAvailable > 0)
return (sum = sumAvailable / price);
return (sum = “please, type at least one number”);
};
bitcoinAvailable(price, sumAvailable);
typeof sum === “number”
? console.log(You can buy ${sum.toFixed(6)} BTC
)
: console.log(sum);
Thank you in advance everyone who give me feedback in their earlier convenience