0

Can you please help me,
Here two for loops, once the first iteration ends, need to begin new line

for (var i = 0; i < 2; i++) {
    for (var j = 0; j < 6; j++) {
        document.write(j);
    }
}​

Need output like this,

012345
012345

Pleas give me the solution.

1
  • Use <br /> for a line break Commented Aug 30, 2012 at 9:24

4 Answers 4

2
for (var i = 0; i < 2; i++) {
    for (var j = 0; j < 6; j++) {
        document.write(j);
    }
    document.write('<br />');
}​
Sign up to request clarification or add additional context in comments.

Comments

1

Here is your code :

for (var i = 0; i < 2; i++) {
    for (var j = 0; j < 6; j++) {
        document.write(j);
    }
    document.write('<br/>');
}​

Comments

1

<div id="append"></div>​​​​​​​​​​​​​​​​​​​​​​​​
<script type="text/javascript">
    for (var i = 0; i < 2; i++) {
        for (var j = 0; j < 6; j++) {
            $('#append').append(j);
        }
        $('#append').append('<br />');
    }​
</script>

Comments

1

Tried this?

for (var i = 0; i < 2; i++) {
    for (var j = 0; j < 6; j++) {
        document.write(j);
    }
    document.write('<br/>');
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.