Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

89
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!