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.