Copy link to clipboard
Copied
Hello!
How one can separate the contents with split() or something else? In the following case it doesn´t work. Okay, I think it´s becausse it is a multidimensional array. Isn´t it?
var string1 = "first string";
var string2 = "second string";
var string3 = "third string";
var string4 = "fourth string";
var string5 = "fifth string";
var x = new Array();
x = [string1, string2, string3, string4, string5];
alert(x.split());
What I want to have is an alert-output like:
first string
second string
third string
fourth string
fifth string
Hi cmoke73,
you already have an array in variable x . Method split() is not available for arrays. That's a method for a string.
Instead use join() with a seperator charakter like that:
alert( x.join("\r") );
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Hi cmoke73,
you already have an array in variable x . Method split() is not available for arrays. That's a method for a string.
Instead use join() with a seperator charakter like that:
alert( x.join("\r") );
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
So simple! (if one knows the answer)
But illogical for me, because join means to attach, to bind, to connect. Not to devide, to separate. 😞
Thank you Uwe
Find more inspiration, events, and resources on the new Adobe Community
Explore Now