Puzzle Reduce code

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

I am not entirely sure how you are running this. Are you changing the sumAvailable variable from string to number manually? Anyways, I tried not to mess with your structure too much, besides formatting and fixing some typos.

const price = 21000;
const sumAvailable = "10000";

const bitCoinAvailable = (price, sumAvailable) => {
  if (typeof sumAvailable === "number" && sumAvailable > 0) {
    return sumAvailable / price;
  }

  return "please, type at least one number";
};

const sum = bitCoinAvailable(price, sumAvailable);

typeof sum === "number"
  ? console.log(`You can buy ${sum.toFixed(6)} BTC`)
  : console.log(sum);