Skip to main content
M.Hasanin
Inspiring
April 11, 2021
Answered

Convert One Line List to Multiple Line in the Script

  • April 11, 2021
  • 2 replies
  • 653 views

Hi Experts

Im Wondering How do I Convert Long List in My Script to Small One?, I have a list of numbers Look like :

 

MyList = ["1", "2", "3", "4", "5", etc to----> ,"1000"]

 

So it is so long in the script , So how i can make it appear divided in Multiple Lines? My Question is How to make the multiple return automatically (it will create multiple lines of the list) ?

Thanks in Advance

Best

M.Hasanain

This topic has been closed for replies.
Correct answer Manan Joshi

Maybe you could try the wrap feature of editors and define the no. of characters after which the code line has to be wrapped to the next line. You could use soft wrap if just the appearance of the line is what you need, but you don't want to insert an actual newline character. See the following

https://stackoverflow.com/questions/319925/difference-between-hard-wrap-and-soft-wrap

-Manan

2 replies

Community Expert
April 11, 2021

If it's about splitting the array definition across multiple lines then you can try the following

var MyList = [1,
2,3, 
4, 
5]
alert(MyList)

-Manan

-Manan
M.Hasanin
M.HasaninAuthor
Inspiring
April 11, 2021

Thank You Mr.Manan But My Question is How to make the multiple return automatically ? do you think it can be done automatically?

Mohammad Hasanin
Manan JoshiCommunity ExpertCorrect answer
Community Expert
April 11, 2021

Maybe you could try the wrap feature of editors and define the no. of characters after which the code line has to be wrapped to the next line. You could use soft wrap if just the appearance of the line is what you need, but you don't want to insert an actual newline character. See the following

https://stackoverflow.com/questions/319925/difference-between-hard-wrap-and-soft-wrap

-Manan

-Manan
brian_p_dts
Community Expert
Community Expert
April 11, 2021

I don't really understand but, ... a for loop?

var makeArr = function() {

var a = new Array(1000);  

for (var i = 0; i < 1000; i++) {

     a[i] = i + 1 + "";

}

return a;

}

var MyList = makeArr();

 

Otherwise, you can put as many return marks as you want in the code:

a =["1","2","3",

"4","5","6",

"7","8","9",

//Etc

];

 

M.Hasanin
M.HasaninAuthor
Inspiring
April 11, 2021

Thanks Mr.brianp311 for your reply, yes the second answer is what i mean, so how i can put many return marks in my code autmatically ? Like you showed me here :

a =["1","2","3",
"4","5","6",
"7","8","9",
//Etc
];

Thank You again

Mohammad Hasanin