Q:

JS - How to start from new line inside for loop? 

I am trying to print 6 random numbers after clicking a button.  Then every time I click the button again, random numbers should start from new line however I do not know how.  I tried everything and nothing works.  I appreciate any help. 

        function fname() {
            for(i=1; i<=6; i++) {
                    number = number + Math.floor(Math.random() * 47 + 1) + "-";
                    var print = number + " GOOD LUCK!"; 
            }
            document.getElementById("total").value = print;
        }
<! DOCTYPE html>
<html>
    <head>
        <title>Let's ROLL!</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <style>
            input, button {display: block;}
        </style>
        <script>
        var number = "";
        function fname() {
            for(i=1; i<=6; i++) {
                    number = number + Math.floor(Math.random() * 47 + 1) + "-";
                    var print = number + " GOOD LUCK!"; 
            }
            document.getElementById("total").value = print;
        }
        </script>
    </head>
    <body>
        <div>
            <button onclick="fname()">ROLL!</button>
            <textarea id="total" rows="12" cols="50" readonly></textarea>
        </div>
    </body>
</html>

A:

Not 100% clear on where you wanted the breaks, but in a text area, a line break is \n.   If this was in an HTML element, you would use <br />. 

var number = "";

function fname() {
  for (i = 1; i <= 6; i++) {
    number = number + Math.floor(Math.random() * 47 + 1) + "-";
  }
  number = number + "\n";
  
  var print = number + "GOOD LUCK!"; 
  document.getElementById("total").value = print;
}
 input,
 button {
   display: block;
 }
<div>
  <button onclick="fname()">ROLL!</button>
  <textarea id="total" rows="12" cols="50" readonly></textarea>
</div>

