I am bit confused with one problem, the problem demands the following : the function min (a, b) to returns the number a if a <b, and returns the number b if b <a. .Take the following piece of code:
export default function min(a,b) {
return a<b ? a:b;
}
let x = min(2,5);
console.log(x);
let y = min(6,3);
console.log(y);
The code runs normally in IDE but when I try to pass it to gitlab via ubuntu it comes out undefined == 2. the test wants the following :
import min from "../test.js";
import assert from "assert";
describe("\n\ntest_", () => {
it("should return 2 for [2,5]", () => {
assert.equal(min([2, 5]), 2);
});
it("should return 3 for [6,3]", () => {
assert.equal(min([6, 3]), 3);
});
});
I can not understand why it does not pass.
You could take another function by taking the parameter as array.
function min(values) {
return Math.min(...values);
}