Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8189749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:23:12+00:00 2026-06-07T03:23:12+00:00

I have a simple one dimensional array but I want to split the long

  • 0

I have a simple one dimensional array but I want to split the long list into two columns using jQuery. How can I achieve this?

var articles = ['article10','article9','article8','article7','article6','article5','article4','article3', 'article2', 'article1'];
for ( var articCounter = articles.length; articCounter > 0; articCounter--) {
    document.write('<a href="../articles/' + articles[articCounter-1] + '.pdf" > ' + articles[articCounter-1] + '</a></br>');  
} // end for

I don’t want to have to create two different arrays for two different float divs….
I’ve googled this many times but many other methods deal with multidimensional arrays.

Thank you very much for the help in advance.

EDIT: Right now it’s just one long list like so:

Article1
Article2
Article3
….

But I would like to achieve this:
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:23:14+00:00Added an answer on June 7, 2026 at 3:23 am

    This will split your array into 2 arrays:

    var articles = ["article1", "article2", "article3", "article4", "article5", "article6", "article7", "article8", "article9", "article10"];   
    var separatorIndex = articles.length & 0x1 ? (articles.length+1)/2 : articles.length/2;
    
    var firstChunk = articles.slice(0,separatorIndex); 
    //["article1", "article2", "article3", "article4", "article5"] 
    var secondChunk = articles.slice(separatorIndex,articles.length); 
    //["article6", "article7", "article8", "article9", "article10"] 
    

    Then you can use them where and/or how you want.

    Explanation

    The 2nd line finds an anchor index (alias -> middle index of division),by which array should be divided into 2 chunks. The array can have odd and even lengths,and those 2 situations must be distinguished. As it is impossible to divide odd-length array into 2 equal parts, it must be divided in such way, that 1st chunk will have 1 element more or less,than 2nd chunk.Here, I have implemented first case,that is, 1st chunk will have 1 element more,than 2nd one. Here are the examples of different situations:

    total length | 1st (length) | 2st (length) | separatorIndex 
        10            0-4 (5)        5-9 (5)          5        
        11            0-5 (6)       6-10 (5)          6
        12            0-5 (6)       0-11 (6)          6
    

    In table, number–number syntax shows accordingly start and end indexes in array. The division is done by .slice() function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of documents, where each document have another simple one-dimensional array
I have a super-simple query in a star schema. One fact, two dimensions. I
I have an Asp .net page like this simple one http://issamsoft.com/app2/page1.aspx and I want
This might be a simple one, but since I don't have much knowledge about
I have an array like this (one dimension only): $arr = array('one', 'two', 'three',
I have a multidimensional array, which I want to initialize in a simple and
I have really stuck on two Java related issues. One simple and one more
I have two-dimensional array of integers. First index indicates the number of channels. The
Suppose I have a simple multidimensional structure, like this one: somestr<-array(sample.int(2, 120, replace=TRUE), dim=c(4,5,6))
I've been working in Python with an array which contains a one-dimensional list of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.