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 8068971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:51:41+00:00 2026-06-05T12:51:41+00:00

I have a string build form comma separated values I use split to get

  • 0

I have a string build form comma separated values I use split to get each value and after that I want to show each value on a new line but what really happens is that I get each value on a new line except of the last two which are shown together on a same line. Just to make it clear:

value1

,value2

,value3

,value4,value5

Here is the function which I’m using:

_checkDates: function(dates) {
    if (dates != null)
    {
        var zzz = dates.split(',');
        var xxx = zzz.length;
        console.log(xxx);
        for (var i=0; i<=xxx; i++)
        {
            zzz[i] = zzz[i] + '<br />';
            return zzz;
        }
    }
    return dates;
}

Just to be clear this is written in ExtJS 4, I’m almost sure that in this case the problem is pure JavaScript and is not related with ExtJS 4 but anyways, maybe I’m wrong.

So any ideas why does it happen and how I could make that last element to get on a new line as well?

  • 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-05T12:51:43+00:00Added an answer on June 5, 2026 at 12:51 pm

    The for-loop is suspicious. Firstly, you do not process all items (the last one is missing, as @sarfraz pointed out). Sencondly you are returning the result (zzz) in the for-loop body:

    for (var i=0; i<=xxx; i++)
    {
      zzz[i] = zzz[i] + '<br />';
      return zzz; // for-loop will stop here! resulting in ["value1<br />", "Value2", etc...]
    }
    

    In Javscript you can simple “join” the array:

    return dates.split(',').join("<br />")
    

    Since you are simply replacing strings you could use the replace method:

    return dates.replace(",", "<br />");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom class that I use to build table strings. I would
I want to build a login form that displays in a sidebar across every
I want to build a form to store some data. A Tarea could have
I have this c# code that builds a string of comma seperated matches for
I have a program that I want each person to have their own tab,
I have to build a registration form using asp.net mvc 3 jquery validate. That
I have query that is build from user's inputs ( passed via html form).
I have a form I've built in PHP and storing the form field values
(java 1.5) I have a need to build up a String, in pieces. I'm
I have a javascript question. I'm trying to dynamically build a plugins string variable

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.