Creating multiplication table using js loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Creating multiplication table using js loop

<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <script> //simple multiplication table for(let i = 1; i < 13 ; i++){ for(let j = 1; j < 13 ; j++){ console.log(`${j} x ${i} = ${j*i}`) } } /* =The outer loop counts up from i=1 to i=12. For every iteration of the outer loop, the inner loop counts up from j=1 to j=12. This means that it starts in the first iteration with i = 1 and j = 1, producing the following output that is logged to the console: << 1 multiplied by 1 is 1 In the next iteration, we are still inside the inner loop, so i remains as 1, but j is incremented to 2, giving: << 1 multiplied by 2 is 2 j continues to increase until it reaches 12. After this, we leave the inner loop and return to the outer loop, where i increases to 2. We then re-enter the inner loop and j is reset back to 1 and begins counting up to 12 again. This continues until the last iteration produces the line: << 12 multiplied by 12 is 144 */ </script> </body> </html>

11th Oct 2018, 1:53 PM
Adebayo David Kismet
Adebayo David Kismet - avatar
1 Answer
+ 1
It's the second one. What is the question? I think you have posted this in wrong part of SL. You can add a code (fourth top layer then on the plus). I think that's what you want to. It is also helpful because you can run your program. Now you are in the question part and well, I see source code but no question. Correct me if I am wrong 😊
12th Oct 2018, 7:11 AM
T M
T M - avatar