Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
Function min(a,b) in Javascript. I'm a bit confused

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could take another function by taking the parameter as array.

function min(values) {
    return Math.min(...values);
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!