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

154
Views
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 answers
Answer question

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 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!