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

124
Vistas
Why I'm I getting undefined in front of the string?

function printOutput() {
    let str1 = window.prompt("Enter the first string");
    let str2 = window.prompt("Enter the Second string");
    let strTemp = str1;
    let strlen1 = str1.length;
    let strlen2 = str2.length;
    for (let i = 0; i < strlen1; i++) {
        for (let j = 0; j < strlen2; j++) {     
            if (str1.charAt(i) === str2.charAt(j)) {
                str1 = str1.replace(str1.charAt(i));
            }
        }
    }

    for (let i = 0; i < strlen2; i++) {

        for (let j = 0; j < strlen1; j++) {

            if (str2.charAt(i) === strTemp.charAt(j)) {
                str2 = str2.replace(str2.charAt(i));
            }
        }
    }
    console.log(str1,str2);
}
printOutput();

  1. Why I'm not getting the ouput properly.
  2. I'm getting undefined in front of the string ?
  3. What could be the solution ?
about 4 years ago · Santiago Gelvez
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