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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:30:56+00:00 2026-06-16T06:30:56+00:00

I have an array [hello, there, buddy] and I want to join these strings

  • 0

I have an array ["hello", "there", "buddy"] and I want to join these strings together. The issue is that I want to join them together with multiple white-spaces, specifically three of them. My code runs as

sentence = sentence.join("   ")

However, instead of returning

hello   there   buddy

it returns as

hello there buddy

How do I fix this?

  • 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-16T06:30:58+00:00Added an answer on June 16, 2026 at 6:30 am

    The text is within a li tag. The page source shows

  2. Hello there buddy
  3. The problem is that browsers collapse whitespace runs between words. You can see this, and counter it, a couple ways.

    <p>1   2   3</p>
    

    displays with multiple spaces here on Stack Overflow, and consequently your browser, because I told it to use code formatting. I can do it also with:

    1   2   3

    which tells the browser to display using <pre> formatting, which, again, is a fixed-width font which respects the whitespaces.

    If you don’t use a fixed-width format designed to preserve whitespace, you have to get tricky.

    In HTML you can use a non-breaking space:

    1   2   3

    which, in HTML looks like:

    1&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;3
    

    If I’d used regular whitespace it would look like:

    1 2 3

    There are CSS games that can be played too, but using &nbsp; is probably the most common.

    To try this at home, save the following to a file called “test.html” and open it with your browser:

    <html><body><p>collapsed    whitespaces   here</p>
    <p>non-breaking&nbsp;&nbsp;&nbsp;spaces&nbsp;&nbsp;&nbsp;here</p>
    </body></html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array that I want to find the number of string 'hello'
Hello I was trying to remove objects from object array that I have and
Hello i have 2 arrays and and i want to put them in a
Hello I have an array of persons, and i am trying to sort them
HEllo, I have a situation here i have contents(NSStrings) in an array, is there
Hello there I have a database that has 2 tables in it, one is
hello every one i want to ask that i have read that we can
Hello i got a question, i have a session array called 'addToCart', in there
Let's say I have these two arrays: string[] arr1 = new string[2]{Hello, Stack} string[]
Let's say I have an array like this: $array = array (this,is,me,and,I,am,an,array,hello,beautiful,world); How can

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.