This code is returning 268, but it's returning 268 as a number when I'd like for it to return 134134 as a string:
function numbersToStrings(input1, input2) {
let newString = " ";
if (input1 === Number) {
input1 = input1.toString();
}
if (input2 === Number) {
input2 = input2.toString();
}
return input1 + input2;
}
console.log(numbersToStrings(134, 134));
I've checked if the input is a number with if (input1 === Number) - is that not a valid way to check if something is a number in JavaScript?
I'm working on a problem that does not allow the use of .concat() or .join(), so please tell me why my number check isn't working, or why .toString() isn't working.
Thanks.
typeof input1 === "number"Numberfunction. And there is only one value for which this is true,Numberitself.Numberis the global objectwindow.Number, which definitely isn't what you want134 + 134to be 268 as a string or134134?return `${input1}${input2}`