Click here to Skip to main content
14,391,880 members
Rate this:
Please Sign up or sign in to vote.
See more:
Here's what I have:
var LAT = "123"
var LNG = "456"
var FOO = { lat: 123, lng: 456 };

How do I use variables in FOO?
var FOO = { lat: LAT, lng: LNG }; <- this is my problem. How to I reference the variables above?

What I have tried:

FOO = {
"lat: " + LAT + ", lng: " + "LNG"
};
Posted
Updated 30-Oct-19 21:33pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Try this:

var FOO = { "lat": LAT, "lng": LNG };


Also read up on some JS.
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100