Answer the question
In order to leave comments, you need to log in
How to pass the result to an object as numbers?
Good day.
Tell me how to make the array result in numbers, not strings, and the result can be transferred to an object (for example, coordinates)?
const loc = {
lat: [35.65000, 35.70000],
lng: [139.70000, 139.80000]
};
const getRandomLocation = loc => _ => {
const [lat, lng] = Object.values(loc).map(([min, max]) => (Math.random() * (max - min) + min) .toFixed(5));
return [lat, lng]
};
const RandomLocation = getRandomLocation(loc);
for (let i = 0; i < 1; i++)
RandomLocation()
Answer the question
In order to leave comments, you need to log in
Put + in front of the variable
Example
let a = "12";
let b = +a;
console.log(typeof(a),typeof(b));
let a = "12";
let b = Number(a);
console.log(typeof(a),typeof(b));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question