I get a “>” appear in my HTML that shouldn’t be there [closed]

I have produced an HTML file that uses some (i.e. loads) of javascript to make the code more flexible.
Sadly, a lot of the javascript is specific to one task, but …
I have written some javascript to populate a div with a table (and do some other “stuff”).
I have used similar javascript to produce a number of tables without issue, but this one is puzzling me.
The table that is frustrating me has an “>” where none should be, and I cannot figure out why.
I am sure it will be an “obvious” error, but I am not familiar with HTML/ … to be confident.
I use a class to have the table displayed without a border (used in a number of other tables).
I generate the code to populate the “div” where some of the code is as follows:-

I am running my webpage off an internal server (Apache2), and I have seen the issue with my tablet and two different Ubuntu laptops, on the following browsers – Brave, Chromium, Edge, Safari and Firefox.

The output of the HTML page is:-

Screenshot of issue

In text (the formatting may not work, but …:-

Edit programme

R> X Programme Name:

The following is the console.log output of the string created over the relevant part.

I would note that in the example below, to try to highlight where the issue is, I added the “R” and “X” around the <td ... > to show where the “>” crops up.

The HTML code I am highlighting in the console.log output is between the two “#”‘s to show if I have added any odd elements.


divstr = #<br>
 <h2>Edit programme</h2>
 <br>
 <table class="tableNoBorder">
 <tr class="tableNoBorder">
 R<td class="tableNoBorder">X #

The HTML from the debug window is as follows (in the “relevant” area!):-


<br>
<h2>Edit programme</h2>
<br>
       
                R&gt;<table class="tableNoBorder">
            <tbody><tr class="tableNoBorder"><td class="tableNoBorder">X

Here,the erroneous “>” appears in a place that doesn’t make sense to me (seen as the “>” before the <table ....

Any clues as to what I am doing wrong would be most appreciated, as I have looked through lots of the code around area, and to ensure the cell, row and table elements are “closed” with the appropriate HTML tags.

Many thanks for any help.

I have replaced the assumed “guilty” tags (<table ..., <tr... & <td ....) with “working ones, without any changes!