jimfog Posted October 12, 2013 Share Posted October 12, 2013 Below it is a code for ternary operator syntax, I cannot understand why the editor shows it as wrong: var url==''? var fields = ['address', 'city', 'municipality']:var fields = ['address', 'city', 'νοmunicipality','url']; Do you see anything wrong with the above? Link to comment Share on other sites More sharing options...
Ingolme Posted October 12, 2013 Share Posted October 12, 2013 Did the error console tell you anything? Prepending that with "var" makes the whole statement a syntax error. I'd do it this way: var fields = (url == "" ? ['address', 'city', 'municipality'] : ['address', 'city', 'νοmunicipality','url']); If url isn't set the program will throw an error. 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