0

I am trying to concatenate a string to another string until the last value is reached:

var z = 0;
while(z < columns.length) { 
    url = url + delimiter;
    z++;
    break;
}

This however seems to add my delimiter to the very end of my url, how can this be fixed?

e.g. what I want:

 url|dilimeter|url|dilimeter|url 

what I get:

 url|dilimeter|url|dilimeter|url|dilimiter 

Note: I have the break statement because this is inside a for loop

1
  • z can start with 1. var z=1 Commented Dec 10, 2013 at 16:37

1 Answer 1

2

You could do:

var z = 0;
var urlParts = [];

while(z < columns.length) { 
    urlParts.push( url );
    z++;
    break;
}

url = urlParts.join( delimiter );
Sign up to request clarification or add additional context in comments.

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.