const a = "ssss"; const fix = (num) => { if (num && typeof(num) === "number") { return num.toFixed("2"); } return "error"; } console.log(fix(a));