It might be easiest to just handle all cases of the new line character instead of checking which case then applying it. For example, if you need to replace the newline then do the following:
htmlstring = stringContainingNewLines.replace(/(\r\n|\n|\r)/gm, "<br>");