Jump to content

loop through array and make 1 big string


chronister

Recommended Posts

Hello all..

 

I suck at javascript and have been messing with this today throughought the last few hours little by little.

 

I have an array or collection of objects or whatever the term is. (they are strings of <p>TEXT HERE</p> tags)

 

I can loop through and get the innerText properly, but I am having trouble taking those and making a string out of each one.

 

I have this so far....

 

     

copyText = $(".copy p.copyString");     
         
        for(i=0;i < copyText.length; i++){
           newString = copyText.innerText;
        }  

 

If I print or alert the newString var, it contains the text I am trying to get to. How would I concatenate these into a string?

 

I have tried join, concat, using the + sign and I want to basically seperate them with a "\n"

 

Thanks for your help.

 

Nate

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.