Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda