8 months ago

I need some serious help with JavaScript.

Out of all the stupid bugs I've encountered, this is by far the worst.


The following code should remove any \n and replace them with an empty space and then split the string into an array:


letarray = code.value.replace("\n", " ").split(" ");


code is a html textarea element:


JS:

constcode = document.querySelector("#code");

HTML:

<textarea id="code" cols="60" rows="30">text = simple\ntext = line\ntext = program</textarea>


code.value is set to:


'text = simple\ntext = line\ntext = program'


The following is what it returns:


['text', '=', 'simple', 'text', '=', 'line\ntext', '=', 'program']


What it should return:


['text', '=', 'simple', 'text', '=', 'line', 'text', '=', 'program']


Please help - I'm starting to go insane because of this stupid little bug.



0 comments

Loading...

Next up

Right... I forgot about this...

Ezzzzz

I made a new OC ... blame it all on @swiftcod3

-

(Read the article for lore, why, and info about what I'll be drawing in the future)

P.S. I'm still learning anatomy, so don't mind it being a little rough around some parts.

Welcome to 'Mytherland' - a brand new interactive community website which will open very soon: https://myther.land

I'm not sure if this counts as a TV show but it is a sitcom so, maybe? Idk either way my favourite TV show is probably the IT Crowd. #TVDay

What's your favourite TV show?

I know have a Bluesky account because... YES

https://bsky.app/profile/endper.bsky.social

I keep on forgetting to do it at the end of the week XD

Mb.

Either way, JEEZZZZ!

THANK YOU @Bored_Dude , @Sarnes , @MatticraftAccelerant , and @workertr VERY MUNCHLY!!

Stickit' Truddy, web-project introduction

A website where you can Collect and Swap stickers with friends and fill up your collector's albums!

Join dev journey at gamejolt.com/c/stickit-kt5adm

#webdev #art

VERY YUMMY THANKIE TO @MatticraftAccelerant , @Bored_Dude , @Salee , and @Sarnes FOR THE YUMMY STICKERS