I started out by trying the following:
var output = document.form1.myTextarea.value.replace("\n", "<br />");
A quick change was required to the code as follows:
var output = document.form1.myTextarea.value.replace(/\n/g, "<br />");
By turning the first parameter into a regular expression and enabling ‘global’ matching (\g), all line breaks were now being converted as expected.