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

247
Visualizações
How to use the splice and binary search on the data to delete and search

I am trying to the splice method but it is not working properly want to delete one user but it is deleting 2.

Also want to add the binary search button

this is the requirement for binary search

Replace the sequential access algorithm to operate on the arrays with a binary search algorithm. To implement this, the array’s data must be sorted. You may refer to an online example available at Array.prototype.sort() to learn about sorting data in arrays.

 function Display_Athlete() {
        var text = "<hr/>";
        for (let i = 0; i < athlete_name.length; i++) {
            text += "Athlete No - " + (i + 1) + ",  Athlete Name is  " + athlete_name[i]
                + "   and height is " + athlete_height[i] + "<br>";
        }
        document.getElementById("message").innerHTML = text;
    }

    //Created function to remove the user
    function Remove_Athlete() {
        var person = prompt("Enter the name to remove the Athlete");
        for (let i = 0; i < athlete_name.length; i++) {
            athlete_name.splice(person - 1, 1);
            athlete_height.splice(person - 1, 1);
            alert("  Athlete_name " + athlete_name + "   Athlete_height  " + athlete_height + "  is removed  ");
        }
    }

    //Create the function to find  the user 
    function Find_Athlete() {
        var person = prompt("Enter the name to Find the Athlete");
        var text = "";
        for (let i = 0; i < athlete_name.length; i++) {
            if (athlete_name[i] == person) {
                text += "Athlete No - " + (i + 1) + ",  Athlete Name is  " + athlete_name[i]
                    + "   and height is " + athlete_height[i] + "<br>";
            }
        }
        document.getElementById("message").innerHTML = text;
        if (text == "")
            alert(`${person} Invalid Athlete name`);
        return "";
    }

    function Binary_Search(){
        
    }
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