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

155
Vistas
generate random number where whole number is the same but the decimals are randomized javascript

I am creating a script to make a very large object to test some filtering functionality in my app.

Each object has a latitude and a longitude which should be a random number. The number needs to be a float and be randomized within certain parameters

latitude: 43.82965739999999
longitude: -79.4702567

How can I generate a random number where the floating points are randomized?

random output 1

latitude: 43.53829
longitude: -79.5234262

random output 2

latitude: 43.908234294234
longitude: -79.19092342
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You just simply use Math.random() in your code, this function always returns a number below 1.

The implementation can be like this

const latitude = 43 + Math.random();
const longitude = -79 - Math.random();
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