(1) a function splits the input in number and string and then an if … else if block checks if number and unit are valid. For some reason all is picked up correctly, but not the case of only a number, without unit. It should return “invalid unit”. But it doesn’t.
function numberStringSplitter(input) {
let inputString = input;
let number = inputString.match(/[.\d\/]+/g) || ["1"];
let string = inputString.match(/[a-zA-Z]+/g)[0];
return [number[0], string];
}
if (!initNum && !initUnit) {
res.send("invalid number and unit");
} else if (!initNum) {
res.send("invalid number");
} else if (!initUnit) {
res.send("invalid unit");
}
(2) In the example project the returnNum is given as number, in my case it is given as string. I cannot find where the problem is. It only does it for returnNum