I need JavaScript code that generates 3 numbers from 1 to 10 hundred times. It should display each set of 3 numbers in a new line, separated by commas, and also display the total number of times when the generated numbers were 7 (also on a separate line). An example output should be formatted as follows: Numeric value 1: 10,7,8 Numeric set 2: 5,1,7 Code that for some reason I do not work
<html> <head> <title>Day 3 - Example 7</title> </head <body> <script language="javascript"> // count number of times seven was generated var i,num,n,num1,num2,cnt=0; n=100; for( i=1; i<=n; i++){ num = Math.floor(Math.random()*10+1); num1 = Math.floor(Math.random()*10+1); num2 = Math.floor(Math.random()*10+1); document.write("Number Set " +i+ is + num,+ num1, +num2); if (num == 7) { cnt++; > } } document.write("<br>Total number of Sevens: " + cnt); </script> </body> </html
source share