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

162
Vistas
exporting function return value

I have a code below

function createRoom(){

  $(document).keyup(function(event) {
      if ($("#room_name").is(":focus") && event.key == "Enter") {
        var plainText = document.querySelector(".create-room-class").value;
        var createRoomName = plainText.replace(/(<([^>]+)>)/gi, "");
        createRoomName = createRoomName.replace(/ +/g, "");
        createRoomName = createRoomName.trim();
        if(createRoomName.length == 0){
            alert("empty");
        } else if(createRoomName.length < 5){
            alert("Room name must be equal or longer than 5 characters");
        } else if(!createRoomName.length == 0)
        {
          getCreatedRoomName(createRoomName);
          window.location = createRoomName;
        }
      }
  });

}

createRoom();

function getCreatedRoomName(x){
  return x;
}

What it does is first checks if input field is not empty and if not smaller than 5 characters. If everything is fine then we pass that value to a function and then redirect to that created name url. Look below.

  getCreatedRoomName(createRoomName);
  window.location = createRoomName;

And we return value (return x)

function getCreatedRoomName(x){
  return x;
}

How can I retrieve that returned value in nodejs? I tried modules it doesn't work for some reason.

about 4 years ago · Santiago Trujillo
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