0

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?

1
  • 1
    Remove + "' at the end. Just use '//domain.com/url/person/" + username Commented Feb 9, 2015 at 1:50

4 Answers 4

4

looks like you have unmatching quote. should be

view.open({ 'post' : '//domain.com/url/person/' + username });
Sign up to request clarification or add additional context in comments.

Comments

2

Change

'//domain.com/url/person/" + username + "'

to

'//domain.com/url/person/' + username

You opened the quotes with ', and didn't close them until the + "'.

Comments

2

Remove the quotes on the username variable

view.open({ 'post' : '//domain.com/url/person/' + username });

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.