Reputation: 880
My code:
var username = some_username;
view.open({ 'post' : '//domain.com/url/person/" + username + "'});
});
username is a variable and I want that variable to be inserted after //domain.com/url/person/". I am new to JS so struggling with this. I was able to do it for other statements using the "+" function but can't seem to get it for this one. What am I doing wrong?
Upvotes: 0
Views: 62
Reputation: 11376
Remove the quotes on the username variable
view.open({ 'post' : '//domain.com/url/person/' + username });
Upvotes: 2
Reputation:
Change
'//domain.com/url/person/" + username + "'
to
'//domain.com/url/person/' + username
You opened the quotes with '
, and didn't close them until the + "'
.
Upvotes: 2
Reputation: 2312
looks like you have unmatching quote. should be
view.open({ 'post' : '//domain.com/url/person/' + username });
Upvotes: 4
Reputation: 68440
There is a wrong string closing. You open with a single quote and close with a double quote, that's not allowed. Also, it is wrong how you end with '"
, you have to remove that. In short, you have to replace it by this
'//domain.com/url/person/' + username
Upvotes: 1