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

90
Visualizações
Add number to array by split and show them in desecnding order after taking input in JS

this is my code. i need to take input from user into an array using split so that i can take multiple number in one form. Then sort them and show in ascending order. plz help

<!DOCTYPE html>
<html>
<body>
  <script>
    var notesArray = Array();

    function array() {
      let splits = document.getElementById("text1").value.split('~');

      for (var i = 0; i < splits.length; i++) {
        notesArray.push(splits[i]);
      }
  
      document.getElementById("text1").value = "";
    }

    function display_array() {
      var e = "<hr/>";

      for (var y = 0; y < notesArray.length; y++) {
        e += "Element " + y + " = " + notesArray[y] + "<br/>";
      }
  
      document.getElementById("Result").innerHTML = e;
    }
  </script>
        
  <form>
    <input type="text" id="text1"></input><br>
    <input type="button" id="button1" value="Add" onclick="array();"></input><br>
    <input type="button" id="button2" value="Display" onclick="display_array();"></input><br>
    <div id="Result"></div>
  </form>
</body>
</html>

my function may not work here. what is the best way to do the sorting?

about 4 years ago · Juan Pablo Isaza
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