How to split a string in the script editor

Is it possible to split a string when using the script editor window? I tried using str.split() function, but it seems like the split() function isn’t enabled for strings.

Instead of rewriting my description template using the awkward markup I though I would use the script editor instead. My template is quite complex and being able to use Javascript would solve a few issues I have with the markup and be much cleaner.

Any ideas?

Can you provide sample code so it’s more clear what you are trying to achieve?

I just played around a bit with the split() function in GarageSale’s script editor and it worked like a charm.

I use split on one of scripts and seems to work in this scope:

function run(){
	for (const listing of selectedListings) {	  
    const titlearray = listing.title.split(" ");
    const firstword = titlearray[0];	  	  
		consoleLog(listing.title);
		consoleLog(firstword);
	}
}

Thanks. I found a better way to do what I needed. But I will test this anyway. It’s possible I did something wrong, I’m usually programming in things other than Javascript. :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.