JSFiddle - React, Tailwind, and code Playground

JavaScript

var mystring = "test<br/>test<br />test";
var cleaner = $('<div />').html(mystring);
cleaner.children('br:last-child').remove();
mystring = cleaner.html();
alert(mystring);