Question

Given the following JavaScript code, what will be displayed on the web page? var i, j;...

Given the following JavaScript code, what will be displayed on the web page?

var i, j;

for (i=1; i<=3; i++)

{

     for (j=2; j<=5; j++)

     {

           document.write(i+ "," + j + "; ");

     }

     document.write("<br>");

}

2,3;
3,4;
4,5;
4,6;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

OUTPUT:

EXPLANATION:

i j Output
1

2

3

4

5

1,2;1,3;1,4;1,5;
2

2

3

4

5

2,2;2,3;2,4;2,5;
3

2

3

4

5

3,2;3,3;3,4;3,5;

For each value of i=1,2,3 inner loop will go through values j=2,3,4,5 and so i,j are printed. After each iteration of i, there is <br> so after each iteration of i, line has been changed.

Add a comment
Know the answer?
Add Answer to:
Given the following JavaScript code, what will be displayed on the web page? var i, j;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Given the following JavaScript code, what will be displayed on the web page? var x =...

    Given the following JavaScript code, what will be displayed on the web page? var x = 5; var y = 12; while (x < y) {      document.write(x);      document.write("<br>");      x=x+3; }

  • Given the following JavaScript code, what will be displayed on the web page? var pho =...

    Given the following JavaScript code, what will be displayed on the web page? var pho = new Array(); for (var i = 0; i< 7; i++) {      pho[i] = (i*i) + 3; }            for (var i = 0; i< 7; i++) {      document.write(i + " => " + pho[i] + "<br>"); } 1 => 4 2 => 7 3 => 12 4 => 19 5 => 28 6 => 39

  • Given the following JavaScript code, what will be displayed on the web page? var k=1; var...

    Given the following JavaScript code, what will be displayed on the web page? var k=1; var m=0; var p=0; while (k<=4) {      k++;      for (p=1; p<=4; p++)      {            document.write(p +" ");      }      document.write("<br>"); }

  • What is the problem with this code? <html> <body> <script type="text/javascript"> //Declare variables var numStudents; var...

    What is the problem with this code? <html> <body> <script type="text/javascript"> //Declare variables var numStudents; var index; var sName; var ES = ""; var BR = "<br />"; var PA = "<p />"; //Print statement document.write("Student Name Entry Program" + PA); //Prompt for number of students to add numStudents = prompt("Enter the number of student names to add: "+ ES); //Loop through numStudents of times, prompting for student names for(index = 1; index <= numStudents: index++) { sName = prompt("Enter...

  • Exercise 30 refer to the following code: var vacation = prompt("What do you want to do...

    Exercise 30 refer to the following code: var vacation = prompt("What do you want to do during Spring Break? ↵ Type S for skiing, F for fishing, H for hiking,8 J for learning JavaScript.", " "); if (vacation == 'S') document.write("You should go to Aspen.<br />"); if (vacation == 'H') document.write("Be sure to buy good hiking boots.<br />"); if (vacation == 'F') document.write("Worms make good bait.<br />"); if (vacation == 'J') document.write("You're gonna have soooo much fun!<br />"); 30. Rewrite...

  • JavaScript 30. What will be displayed after the following code is entered and run if the...

    JavaScript 30. What will be displayed after the following code is entered and run if the user enters "9 am" at the first prompt and "N-215" at the second prompt? If you think there is an error, describe how you would fix it. function examTime() { var time = prompt("What time is the exam?"); var room = prompt("What room is the exam in?"); showIt(time, room); } function showIt(a, b) { document.write("Your exam is in room " + a + "...

  • Consider the following JavaScript skeletal program: //the main program var x: function sub1 () { var...

    Consider the following JavaScript skeletal program: //the main program var x: function sub1 () { var x: function sub2 () { } } function sub3 () { } Assume the execution of this program is in the following unit order: main calls sub1 sub1 calls sub2 sub2 calls sub3 a. Assuming static scoping, which declaration of x is the correct one for a reference to x in: i. sub1 ii. sub2 iii. sub3 b. Repeat part a, but assume dynamic...

  • 1. Given the following code snippet, what is the scope of the variable pen on Line...

    1. Given the following code snippet, what is the scope of the variable pen on Line 1? <script> 1.    var pen = "ball point"; 2.    var pencil = "0.7mm lead"; 3.    function writeIt() 4.    { 5.          document.write(I have a " + pen + " pen."); 6.          pen = "gel ink"; 7.         document.write("You have a " + pen + " pen."); 8.          var pencil = "0.5mm lead"; 9.          document.write("I prefer pencils with " + pencil + "."); 10.   } <script> A. global B....

  • Please help me with the following requirements for JavaScript. Write a function to take a temperature value in Celsius a...

    Please help me with the following requirements for JavaScript. Write a function to take a temperature value in Celsius as an argument and return the equivalent temperature in Fahrenheit, basing it on the code from Hour 2. //Original Code <!DOCTYPE html> <html> <head>     <title>Fahrenheit From Celsius</title> </head> <body>     <script>         var cTemp = 100;  // temperature in Celsius         var hTemp = ((cTemp * 9) /5 ) + 32;         document.write("Temperature in Celsius: " + cTemp + " degrees<br/>");         document.write("Temperature in Fahrenheit: "...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT