Answers for "javascript example"

5

javascript code

html>
<head>
  <title>Multiplication Table</title>
  <script type="text/javascript">
    var rows = prompt("How many rows for your multiplication table?");
    var cols = prompt("How many columns for your multiplication table?");
    if(rows == "" || rows == null)
   		 rows = 10;
    if(cols== "" || cols== null)
   		 cols = 10;
    createTable(rows, cols);
    function createTable(rows, cols)
    {
      var j=1;
      var output = "<table border='1' width='500' cellspacing='0'cellpadding='5'>";
      for(i=1;i<=rows;i++)
      {
    	output = output + "<tr>";
        while(j<=cols)
        {
  		  output = output + "<td>" + i*j + "</td>";
   		  j = j+1;
Posted by: Guest on July-19-2020
0

sample in javascript

function sample(arr, req) {
        arr = arr.sort(()=>{ return 0.5 - Math.random() }) ;
        let i = 0,
            array = [];
        while (i < req) {
            array.push(arr[i])
                ++i
        }
        return array
    }

//example  
let arr = [1,2,3 ,4,5] ;
console.log( sample(arr , 2) )   // will return two  random items
Posted by: Guest on May-15-2021
0

javascript examples

// store input numbers
const num1 = parseInt(prompt('Enter the first number '));
const num2 = parseInt(prompt('Enter the second number '));

//add two numbers
const sum = num1 + num2;

// display the sum
console.log(`The sum of ${num1} and ${num2} is ${sum}`);
Posted by: Guest on March-22-2021
1

javascript code

function getIntoAnArgument() {
    var args = arguments.slice();
    args.forEach(function(arg) {
        console.log(arg);
    });
}
Posted by: Guest on July-19-2020
-1

javascript example

num1 = 34
num1+22
Posted by: Guest on May-24-2021
-2

javascript example

var c = 23;
Console.WriteLine(c);
Posted by: Guest on May-24-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language