<textarea id="text"></textarea>
<div>
  <button id="populate">Populate</button>
  <button id="get">Get & Compare</button>
</div>
<p id="results"></p>
textarea {
  width: 250px;
  height: 100px;
}

button {
  background-color: white;
  padding: 5px;
  min-width: 70px;
  color: cornflowerblue;
  border: 1px solid cornflowerblue;
  border-radius: 5px;
}
const stringWithReturn = "This is the first line\rThis is the second line";
const textAreaElement = document.querySelector('#text');  

document.querySelector('#populate').addEventListener('click',() => {
   textAreaElement.value = stringWithReturn;
});

document.querySelector('#get').addEventListener('click',() => {
   const comparison = textAreaElement.value === stringWithReturn;
   document.querySelector('#results').innerText = `The comparison was ${comparison}`;
   // console.log('textAreaElement.value: ', textAreaElement.value);
   // console.log('stringWithReturn: ',stringWithReturn);
});
                                             

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.