1html>
2<head>
3 <title>Multiplication Table</title>
4 <script type="text/javascript">
5 var rows = prompt("How many rows for your multiplication table?");
6 var cols = prompt("How many columns for your multiplication table?");
7 if(rows == "" || rows == null)
8 rows = 10;
9 if(cols== "" || cols== null)
10 cols = 10;
11 createTable(rows, cols);
12 function createTable(rows, cols)
13 {
14 var j=1;
15 var output = "<table border='1' width='500' cellspacing='0'cellpadding='5'>";
16 for(i=1;i<=rows;i++)
17 {
18 output = output + "<tr>";
19 while(j<=cols)
20 {
21 output = output + "<td>" + i*j + "</td>";
22 j = j+1;
1function sample(arr, req) {
2 arr = arr.sort(()=>{ return 0.5 - Math.random() }) ;
3 let i = 0,
4 array = [];
5 while (i < req) {
6 array.push(arr[i])
7 ++i
8 }
9 return array
10 }
11
12//example
13let arr = [1,2,3 ,4,5] ;
14console.log( sample(arr , 2) ) // will return two random items
1// store input numbers
2const num1 = parseInt(prompt('Enter the first number '));
3const num2 = parseInt(prompt('Enter the second number '));
4
5//add two numbers
6const sum = num1 + num2;
7
8// display the sum
9console.log(`The sum of ${num1} and ${num2} is ${sum}`);
1function getIntoAnArgument() {
2 var args = arguments.slice();
3 args.forEach(function(arg) {
4 console.log(arg);
5 });
6}