• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

258
Views
copiar valores de una matriz a otra matriz

Quiero copiar los valores de genders[x] en otra matriz en JavaScript. Si géneros[x] es "m", quiero copiar los valores en una matriz separada que se llama géneros[m] y si es "f", quiero copiar los valores en la matriz géneros[f].

 m = 0; f = 0; x = 0; function add_element_to_array() { usernames[x] = document.getElementById("name").value; ages[x] = document.getElementById("age").value; genders[x] = document.getElementById("gender").value; gendersM[m] = document.getElementById("gender").value gendersF[f] = document.getElementById("gender").value if ( (correctEingabe == true) && (age == true) ){ ++x; if (genders[x] == "m") { ++m; } if (genders[x] == "f") { ++f; } else { deleteLastArray(); } }

La primera parte funciona perfectamente, así que solo esta parte es importante. Pero de alguna manera no funciona. Estaría muy agradecido por alguna ayuda.

 if (genders[x] == "m") { ++m; } if (genders[x] == "f") { ++f; }
almost 3 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error