Hi! I am working on a project and have an issue with the concat method i am using on 2 arrays. I get a string input from a user:
'abcde' and assign this to var alphabet
then this is the code I am using:

the problem is that when i turn the alphabet input string into an array, i get
a,b,c,d,e,
i notice there is a comma at the end of the e here, but when i create the other array, there is not comma at the end..i think this is then causing the problem below when i concat these arrays.
x,y,z

when i concat the arrays i get:

a,b,c,d,e,,x,y,z
and then when i use .join i get:
abcde xyz
with a gap!

if i concat the other way round, ie. with xyz at the beginning i don't get this problem..
x,y,z,a,b,c,d,e and when i make this a string with .join it is fine i get:
xyzabcde

but i just can't get this to work the way round i need it to!
i have tried the inital .split() as just .split and tried to join the xyz into a string with .join before the concat but it still doesn't work as then i get:
abcde
xyz
and after concat and join:
abcde xyz

so it gives me a gap here!!:confused:

This is driving me nuts! i want to use the concat, split and join methods on arrays here, but can anyone see what might be causing this issue and how i can get rid of it?

Quizmaster: Paris is bigger than Vienna. And Vienna is bigger than Rome. Which is the smallest?
Contestant: Oh, I dunno. Paris?

Jen333

09-08-2008, 02:47 PM

Thank you!! I will try this out. :thumbsup: The reason for using the arrays concat method is just that I am working on this for a exercise and wanted to practice with these methods, but your adding of the variables is certainly the easiest way! thank you again!