0
I am trying to insert strokes that will be according to the number of characters of the variable Athlete’s name, and the whole textSaida are inside a tag <pre>, however only the name and category appear on my page, tracos appears as Undefined. 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Clube de Natacao</title>
</head>
<img src="natacao.jpeg" alt="crianca na piscina">
<h2> Clube de Natacao </h2>
<body>
    <p> Nome <input typet="text" id="txtnome" autofocus> </p>
    <p> Idade <input type="text" id="txtidade"></p>
    <input type="button" id="formBt" value="Categorizar Atleta" onclick="gerarTracos()">
    <h3>
        <pre id="saida"> </pre>
    </h3>
    <script>
        function gerarTracos() {
            var saida = document.getElementById("saida");
            var nomeAtleta = document.getElementById("txtnome").value;
            var nomeAtleta = nomeAtleta.toUpperCase();
            var idadeAtleta = document.getElementById("txtidade").value;
            var i; 
            var textoSaida = nomeAtleta + "<br>" + tracos + "<br>";
            textoSaida += "Categoria: " + categoria(idadeAtleta);
            var comprimento = nomeAtleta.length;
            saida.innerHTML =  textoSaida;
            for (i = 0; i < comprimento; i++) {
                var letra = nomeAtleta.charAt(i);
                var tracos; 
                if (letra != "A" || letra == "B" || letra == "C" || letra == "D" || letra == "E" || letra == "F" || letra == "G" || letra == "H" || letra == "I" || letra == "J" || letra == "K" || letra == "L" || letra == "M" || letra == "N" || letra == "O" || letra == "P" || letra == "Q" || letra == "R" || letra == "S" || letra == "T" || letra == "U" || letra == "V" || letra == "X" || letra == "W" || letra == "Y" || letra == "Z") {
                    tracos += "-";
                }
                else {
                    tracos += " ";
                }
            }
        }
        function categoria(idadeAtleta) {
            if (idadeAtleta <= 12) {
                return "Infantil";
            }
            else if (idadeAtleta > 12 && idadeAtleta < 18) {
                return "Juvenil";
            }
            else if (idadeAtleta > 18) {
                return "Adulto";
            }
        }
    </script>
</body>
</html>
						
You’re not wearing it
tracosin thatfor... where this content should appear?– Sergio
the variable is set just below the for var tracos;
– Ane Mendes
Yes but this function has no Return, so it returns nothing...
– Sergio