Skip to main content

JAVASCRIPT Problems

Hello


Students check these javascript problems

  1. Add new elemts at the beginning of array
    <html >
    <body >
    <script language="javascript" >
    var scripts=new Array();
    scripts[0]="PHP";
    scripts[1]="ASP";
    scripts[2]="JAVASCRIPT";
    scripts[3]="HTML";
    document.write(scripts.join("< br > "));
    document.write("< br >---- NOW AFTER APPLYING unshift()---< br >");
    scripts.unshift("VBSCRIPT","PERL");
    document.write(scripts.join("< br >"));
    </script >
    </body >
    </html >

  2. Display Today's date and Time

    < html >
    < title >
    < /title >
    < body >
    < script language="javascript" >
    var d=new Date;
    document.write("< b > "+d);
    < /script >
    < /body >
    < /html >
  3. Add an element to position 2 in an array
    < html >
    < body >
    < script type="text/javascript" >
    var fruits = ["HTML", "JSP", "PHP", "ASP"];
    document.write("Removed: " + fruits.splice(2,0,"JAVASCRIPT") + "< br / >");
    document.write(fruits);
    < /script >
    < /body >
    < /html >

  4. Concatenate two arrays

    < html >
    < body >
    < h2 > concat arrays containig alphabets,numbers,symbols < /h2 >
    <script language="javascript" >
    var alphabets = ["a","b","c"];
    var numbers = ["1","2"];
    var symbols = ["@", "$","^"];
    var alphano = alphabets.concat(numbers,symbols);
    document.write(alphano);
    < /script >
    < /body >
    < /html >

  5. To concert today's date to string
    < html >
    < body >
    < script language="javascript" >
    var d =new Date();
    document.write("in original form");
    document.write(d +"< br/ > ");
    document.write("(according to UTC) to string:");
    document.write(d.toUTCString());
    < /script >
    < /body >
    < /html >

  6. TO remove first element of the array
    < html >
    < head >
    < title > Removing the first Element < /title >
    < script language="javascript" type="text/javascript" >
    < !--
    var x = new Array(1,2,3,4);
    var firstElement = x.shift();
    alert(firstElement);
    alert(2);
    alert(3);
    alert(4);
    alert(x);
    //-->
    < /script >
    < /head >
    < body >
    < h1 > Removing the first Element < /h1 >
    < /body >
    < /html >

  7. Replace character in a string
    < html>
    < body>
    < script language="javascript" >
    var str="LOGIN UR ID!";
    document.write(str.replace(/ID/,"ACCOUNT"));
    < /script >
    < /body >
    < /html >
  8. Reverse order of elements in the array
    < html >
    < title > JavaScript array reverse() example < /title >
    < body >
    < h2 >
    Example of reversing an array
    < /h2 >
    < script type="text/javascript" >
    var arr = new Array(3);
    arr[0]="1";
    arr[1]="2";
    arr[2]="3";
    document.write("< b > Array before reversed is < /b >="+arr+"< br > ");
    document.write("< b > Reversed array is < /b > ="+arr.reverse()+"<br > ");
    < /script >
    < /body >
    < /html >

compiled by PRAPTI

Comments

Popular posts from this blog

Advantages and Disadvantages of EIS Advantages of EIS Easy for upper-level executives to use, extensive computer experience is not required in operations Provides timely delivery of company summary information Information that is provided is better understood Filters data for management Improves to tracking information Offers efficiency to decision makers Disadvantages of EIS System dependent Limited functionality, by design Information overload for some managers Benefits hard to quantify High implementation costs System may become slow, large, and hard to manage Need good internal processes for data management May lead to less reliable and less secure data

Inter-Organizational Value Chain

The value chain of   a company is part of over all value chain. The over all competitive advantage of an organization is not just dependent on the quality and efficiency of the company and quality of products but also upon the that of its suppliers and wholesalers and retailers it may use. The analysis of overall supply chain is called the value system. Different parts of the value chain 1.  Supplier     2.  Firm       3.   Channel 4 .   Buyer

Big-M Method and Two-Phase Method

Big-M Method The Big-M method of handling instances with artificial  variables is the “commonsense approach”. Essentially, the notion is to make the artificial variables, through their coefficients in the objective function, so costly or unprofitable that any feasible solution to the real problem would be preferred, unless the original instance possessed no feasible solutions at all. But this means that we need to assign, in the objective function, coefficients to the artificial variables that are either very small (maximization problem) or very large (minimization problem); whatever this value,let us call it Big M . In fact, this notion is an old trick in optimization in general; we  simply associate a penalty value with variables that we do not want to be part of an ultimate solution(unless such an outcome is unavoidable). Indeed, the penalty is so costly that unless any of the  respective variables' inclusion is warranted algorithmically, such variables will ...