Bruce432213 Posted May 28, 2019 Share Posted May 28, 2019 (edited) I want to do the following: var colour = blue; fill: 'colour', Thank you Edited May 28, 2019 by Bruce432213 Link to comment Share on other sites More sharing options...
justsomeguy Posted May 28, 2019 Share Posted May 28, 2019 You can use the + operator to concatenate. https://www.w3schools.com/js/js_operators.asp Link to comment Share on other sites More sharing options...
Bruce432213 Posted May 28, 2019 Author Share Posted May 28, 2019 3 hours ago, justsomeguy said: You can use the + operator to concatenate. https://www.w3schools.com/js/js_operators.asp The thing is, '+colour+' results in 'colour' as an entire string. I wan't to have the ' ' as a string and pass in colour like a variable. Link to comment Share on other sites More sharing options...
dsonesuk Posted May 28, 2019 Share Posted May 28, 2019 (edited) var colour = blue ; Will be treated as variable colour equaling variable blue, so it should be var colour = 'blue'; Depending on what, where, how it is used fill: 'colour', In most cases would be used as 'fill: '+colour+', ' If you need quotes then it would be 'fill: " '+colour+' ", ' OR "fill: ' "+colour+" ', " Edited May 28, 2019 by dsonesuk 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now