Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda