Firstly, make your object valid. Then just split
on a comma to extract the desired values.
let obj = {
map: {
geo: "20.471884,-157.5056",
p: "Hawaii"
}
};
const [lat, lng] = obj.map.geo.split(",");
console.log(lat);
console.log(lng);
The name is obj
not location
because location
is reserved.
solved How to get number value of string value that is changing ; javascript [closed]