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

212
Views
Conversión de GB a MB en js

Estoy tratando de agregar una lógica de conversación para convertir 1 GB al valor 1000; 2,5 GB al valor 2500; 50 MB al valor 50; 1 MB al valor 1 y así sucesivamente usando javascript.

Intenté agregar lógica pero comprende múltiples si no.

 var bw; var value; if (bw.toUpperCase() == '1 GB' || bw.toUpperCase() == '1 GBPS') { value = 1000; } else if (bw.toUpperCase() == '2.5 GB' || bw.toUpperCase() == '2.5 GBPS') { value = 2500; }

y así sucesivamente para MB. Los únicos valores que vendrán son GB o MB. Sin kb ni bytes.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Una opción es:

 let units = { GB: 1000, GBPS: 1000, ... }; let [a, b] = yourString.split(' '); let value = +a * units[b];
about 4 years ago · Santiago Gelvez Report
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!