I am new to javascript and trying something with longitude coordinate.
I have 3 longitudes and I want to split and store them till 6 digits after the decimal point
I am able to do only one of them at a time which is not good as these numbers can come dynamically from user input.
For example:
let long1 = 151.21484501290186; // I want to store till 151.214845
let long2 = 77.55814612714227; // I want to store till 77.558146
let long3 = -122.0898574222976; // I want to store till -122.089857
// this method only works if starting value is of 2 digits but failed when it's 3
const result = long2.toString().substr(long2.toString().indexOf('.') - 2, 9);
console.log(result) // 77.558146
Please help me.