Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
How to change the value of the index number of an array so that it would start from 1 instead of 0

How do i make it so that the index starts with 1 instead of 0. Also how would i make it 1st, 2ed, 3rd etc. in instead on 1 2 3 etc.

<p id = "array"></p>        
    <script>
            var car = ["Nissan Skyline R34 GTR", "Toyota Supra A80", "Mazda RX7 FD3S", "Honda NSX Type R", "Nissan 240SX", "Toyoto AE86", "Subaru Impreza WRX Sti", "Honda Civic EG6"];
            
            var text = "";
            car.forEach(script)
            document.getElementById("array").innerHTML = text;
            
            function script (value, index, array) {
              text += ("My #" + index + " choice is " + value + ". <br>");
            }
        </script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

How to change the value of the index number of an array so that it would start from 1 instead of 0

Just answering the question without asking why you want that: You can achieve it by inserting and deleting a dummy element 0.

<p id = "array"></p>        
<script>
    var car = ["", "Nissan Skyline R34 GTR", "Toyota Supra A80", "Mazda RX7 FD3S", "Honda NSX Type R", "Nissan 240SX", "Toyoto AE86", "Subaru Impreza WRX Sti", "Honda Civic EG6"];
    delete car[0]
    var text = "";
    car.forEach(script)
        document.getElementById("array").innerHTML = text;

    function script(value, index, array)
    { text += ("My #" + index + " choice is " + value + ". <br>"); }
</script>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda