Hi, I’m actually trying to complete the first project of Information Security and Quality Assurance Projects. The problem is magically this function return doesn’t past the test. I tried with quincys example and it worked. Now the f@#~@g magic is that if you try it with the console or the api itself it works it returns 32. I try setting the return to a string a it did not work.
this.getNum = function(input) {
let result;
// Find index of unit
let index = /[a-z]/.exec(input).index;
// If index === 0 there are no number. Default 1
if (index === 0) {
return 1;
}
// Let split the input copy it from 0 to Index
let num = input.slice(0, index);
if (input.indexOf("/") == -1) {
result = Number(num);
} else {
inputArr = num.split("/");
if (inputArr > 2) {
return "invalid number";
}
result = Number(inputArr[0]) / Number(inputArr[1]);
}
return result;
};
This is the test
test("Whole number input", function(done) {
var input = "32L";
assert.equal(
convertHandler.getNum(input),
32,
"Int es returned correctly"
);
done();
});