HTML/CSS/JS problem

I was making a basic text-editor-like website for a future project. I was making it with an AI since I had no idea where to start, and now there’s a strange problem: when you press enter, more than one line number is shown (specifically two each time). I’ve tried multiple ways to fix it already, but honestly my JavaScript knowledge is limited so I don’t know how to fix it. (It might not be a problem with the JavaScript, but I’m pretty sure it is.)
Any help is appreciated.

Repl links:
Output & code
Just output

1 Like

The issue here is that in the updateCodeLines function, the for loop to add a line is repeating itself for however many lines are in the code. While you are running your script here, you are adding more lines of code. This is causing the script to repeat itself when it shouldn’t. This entire script is terrible and you should probably just scrap it anyways.
Also, there are tons of other things wrong with this project.
For one, since this is not a <textbox> and it is just an editable <div>, anybody can paste anything they want in there, like pictures and buttons. The contenteditable attribute just allows you to change its innerHTML easily. Here’s an example of when I selected and copied the entire Replit editor and pasted it into your code editor:

In general, using AI to program things like this usually does not work out well. I recommend just doing it on your own while asking AI for help when you get stuck. AI can be a great tool when trying to figure out how to do simple things, like asking it how to output into the console. But when asking it to create something like an entire text editor, it’s probably going to mess it up. I’ve tried.

If you need any help with anything, I can help and the Replit community will always be there so feel free too ask as many questions as you need.

1 Like

Okay, I wasn’t sure and I’m a complete JS noob so I had no idea

Credit goes to the AI

Yeah, I thought that the div contenteditable was a bad idea, I did a similar thing to test what could happen

I know, I was just trying to figure where to begin, and now I have a basic idea, so I’m gonna scrap it

*to

1 Like

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