2 years 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

TANK YOU @Sarnes & @SuperrONNY8 VERY MUCH FOR THE GIFTS!!!

Wait, whaaaaaaaaaaaaaaaa?!?!?!??!

I NOW TAKE ART COMMISSIONS For now, all of them are free

Later this year I will make a new table that looks better and with prices

Slots (5/5) FULL

(Please read the article for example work and more info)

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

My last update post...

The images above are part of my art studies.

(second image is one of my OCs... tbh they're all OCs)

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

"New Package" ft. @Sarnes

Again, was made in July but only finished the rendering on Wednesday.

(2/4 Fan Art Doodles of... me)

"Bullying the Fluffy Soup" ft @Sarnes and @SwiftCod_3

Made in July, rendered yesterday.

(3/4 Fan Art Doodles of... me)

"Where's my yummy!"

I made this all the way back in July.

(1/4 Fan Art Doodles of.... me)