10 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

HUGE THANK YOU TO ALL OF THESE AMAZING PEOPLE FOR THE GIFTS AND SUPPORT

It's finally over. 7 days.

God damn ya all...

Hope ya all are happy

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

I'm on twitch?- pfft no way

https://www.twitch.tv/endperxd

HAPPY NEW YEAR TO EVERYONE

Goodbye 2024 and Welcome 2025

P.S. the article is long asf - if you want to skip over some stuff, all goods.

A couple days ago, I started looking at terrian generation in Godot. This was one of my favourite gens that I got. There are only 6 tile variates, so it looks a bit weird in some places.

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

I'll be streaming Shrine tomorrow (The 9th) at 12pm (NZST) for around 2-3 hours.

https://twitch.tv/endperxd