Skip to main content

Posts

Java-Script

 JavaScript often abbreviated JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS.ver 97% of websites use JavaScript on the client side for web page behavior,often incorporating third-party libraries. All major web browsers have a dedicated JavaScript engine to execute the code on users' devices. JavaScript is a high-level, often just-in-time compiled language that conforms to the ECMAScript standard.It has dynamic typing, prototype-based object-orientation, and first-class functions. It is multi-paradigm, supporting event-driven, functional, and imperative programming styles. It has application programming interfaces (APIs) for working with text, dates, regular expressions, standard data structures, and the Document Object Model (DOM). The ECMAScript standard does not include any input/output (I/O), such as networking, storage, or graphics facilities. In practice, the web browser or other runtime system provides JavaScri...
Recent posts

character at specified position.

<!DOCTYPE html> <html> <head> <title></title> </head> <body> <script>  function cal() {   var r1=document.forms[0];   var a=document.frm.txt.value;   var repeat=0;   var c;       var pos=prompt("Enter Position: ");    var ch=a.charAt(parseInt(pos)-1);    if(ch!="")     alert("character at specified position is: "+ch);    else     alert("Please Enter value between "+ a.length);     } </script> <form name="frm"> Enter the string: <input type="text" name="txt" ><br/> <input type="button" onclick ="cal()" name="b1" value="Submit"> </form> </body> </html>

volume of shpere

<input type="number" id="input_radius" placeholder="Enter the radius"> <input type="button" value="Find" id="input_button" > <script>   function calculateVolume(){     let radius = document.getElementById("input_radius").value;     let volume = (4/3)* Math.PI * Math.pow(radius, 3);     alert("The volume of a sphere: "+volume.toFixed(2)); }      let button=document.getElementById("input_button"); button.onclick=calculateVolume;   </script>

Q.9:-10 Digit Number

 //10 Digit Number <!DOCTYPE html> <html lang="en">   <head>   <title>10 Digit Number</title>    </head>     <body>     <center>     <h1>10 Digit Number</h1>     <script>         var number='12345678950';         var length = number.length;         document.write("length is:" + length+"<br>");         if (number.length == 10)          {           document.write(number +" is 10 digit number");         }         else         {           document.write(number +" is not 10 digit number");         }     </script>   </center>   </body> </html> 👉 Execute 👈

Q.1:-Palindrome Number

 //Palindrome Number <!DOCTYPE html> <html> <body> <center> <h1>Palindrome Number</h1> <script> var num = 120; var copyNum = num; var reverse = 0; //reverse a number while(copyNum != 0) {   reverse = reverse * 10;   reverse = reverse + (copyNum % 10);   copyNum = Math.floor(copyNum / 10); } // result if (num == reverse)   document.write(num +" is a palindrome number"); else   document.write(num +" is not a palindrome number"); </script> </center> </body> </html> 👉 Execute 👈

Q.1:-Multiplication Table

 //Multiplication Table <!DOCTYPE html> <html lang="en">   <head>   <title>Multiplication Table</title>    </head>     <body>     <center>     <h1>Multiplication Table</h1>     <script>       function addNumbers() {         var number;         var result = "";         number = Number(document.getElementById("number").value);         for(var i = 1; i<= 10; i++){           result = result + "<p>"+number + "*" + i + "=" + number * i+"</p>";         }         document.getElementById("result").innerHTML = result;       }     </script>   <br>        Enter the number : <input id="number" /><br><br>   ...

Q.8:-Verification of valid Password

//Verification of Valid Password   <html>   <head>   <title> Verification of Valid Password </title>   </head>   <script>   function verifyPassword() {     var pw = document.getElementById("pswd").value;     var cpw = document.getElementById("cpswd").value;   //check empty password field     if(pw == "") {        document.getElementById("message").innerHTML = "**Field Should Not Be Empty!";        return false;     }      if(cpw == "") {        document.getElementById("message").innerHTML = "**Field Should Not Be Empty!";        return false;     }       if (pw == cpw)      {       alert("Password is Correct..!!");       }   ...

//Function:-Arthmatic Operation

Function:-Arthmatic Operation  <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script type="text/javascript"> //Function Arthmatic Operation //Addition function add(a , b) //function name must start with letter or underscore. { var c = a + b; document.write("the add is:"+c+"<br>"); } add(40, 50); //Function Call:- You can many times call function. add (45, 45);  //you can add many argumentsas you want. //Subtraction function sub(a , b)  { var c = a - b; document.write("the sub is:"+c+"<br>"); } sub(100, 50); //100, 50 this value store in 'a' and 'b', then execute operation "100 - 50= 50". //Division function div(a , b)  { var c = a / b; document.write("the div is:"+c+"<br>"); // +c+ is used to indicate which value should be print. } div(100, 4); //...

//Switch Case (String)

Switch Case (String)  <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script type="text/javascript"> //Switch String:- In Switch String we use words and numbers in "duble quotes". var a = 30; var b = 20; var c; var string = "six"; //which case you want to execute 'Enter' case. switch(string) { case "one": //the case label must be end with colon(:) { c = a + b; document.write("the add of a + b is:"+c+"<br>"); break; //It's necessary to use break after each block. } case "two": //case label must be unique. { c = a - b; document.write("the subtraction a - b is:"+c+"<br>");//"<br>" use for linebreak. break; //if you don't use it, then all cases executed. } case "three": { c = a / b; document.write(...

//Switch Case (Integer)

Switch Case (Integer)  <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script type="text/javascript"> //Switch Integer:- In Switch Integer we use Numbers(integers) var a = 30; var b = 20; var c; var int = 4; //which case you want to execute 'Enter' case value. switch(int) { case 1: //the case label must end with colon(:) { //Addition c = a + b; document.write("the add of a + b is:"+c+"<br>"); // document.write() use for print line. break; //It's necessary to use break after each block. } case 2: { //Subtract c = a - b; document.write("the subtraction a - b is:"+c+"<br>"); //"<br>" use for linebreak. break; //if you don't use it, then all cases executed. } case "3": { //Division c = a / b; document.write("the divisio...

//Switch Case (Character)

Switch Case (Character)   <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script type="text/javascript"> //Switch Char:- In switch char we use character for ex. + ,-, *, /, %, @ var a = 30; var b = 20; var c; var ch = '*'; //which case you want to execute 'Enter' case value. switch(ch) { //Addition case "+":  //the case label must be end with colon(:) { c = a + b; document.write("the add of a + b is:"+c+"<br>");//"<br>" use for linebreak. break; //It's necessary to use break after each block. } //Subtract case "-": //case label must be unique. { c = a - b; document.write("the subtraction a - b is:"+c+"<br>"); // document.write() use for print line. break; //if you don't use it, then all cases executed. } //Division case ...

//If-Else-If:Grade

If-Else-If:Grade   <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script type="text/javascript"> var s1 = 38; var s2 = 34; var s3 = 35; var s4 = 35; var s5 = 36; var per; var per2; // Addition of All Subject Marks per = s1 + s2 + s3 + s4 + s5;      //Separate The Arthmatic Opration Everytime.. per2 = per / 5; document.write("Persentage:"+per2+"<br>"); if (per2 >= 90)  { document.write("Grade:A"); }  else if (per2 >= 80)  { document.write("Grade:B"); } else if (per2 >= 70)  { document.write("Grade:C"); } else if (per2 >= 60)  { document.write("Grade:D"); } else if (per2 >= 40)  { document.write("Grade:E"); } else { document.write("Fail"); } </script> </body> </html> // Execute //...

//Forloop

For Loop   <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script type="text/javascript"> //forloop //print 10 to 20 var a; for (var a = 10; a <= 20; a++) // (a=10 is initialization statement);(a<=20 is test condition                                                            statement);(a++ is increment statement)                          //Initialization:-the control-variable is done first, using assignment                                                  statement such as a=10 or count=0.             ...

// Dowhile

Do while   <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script type="text/javascript"> // Dowhile  //print number 20 to 40           var a = 20; do // the body of the loop is excuted at least once time. { document.write("the value of a is: "+a+"<br>"); // document.write() use for print line. a++;                                           //(a=20 <= 40) the condition is True; therefore execute                                                                    conditional code. }while(a <= 40)              ...

//while loop

While Loop   <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script type="text/javascript"> //while loop //print number from 10 to 20 var a = 10; while(a <= 20) //(a=10 <= 20) the condition is True; therefore excute conditional code.               //when condition is true then excute conditional code; otherwise loop body skipped. { //the body of loop document.write("the value of a is:"+a+"<br>") a++; // a++ for this condition 'a <= 20'. value increase upto 20. } </script> </body> </html> // Excute //Output /*the value of a is: 10 the value of a is: 11 the value of a is: 12 the value of a is: 13 the value of a is: 14 the value of a is: 15 the value of a is: 16 the value of a is: 17 the value of a is: 18 the value of a is: 19 the value of a is: 20*/               ...

//Break And Continue Statement

Break And Continue Statement  <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script type="text/javascript"> var a = 10; while(a <= 20) { if (a == 15) //(a==15)when... block of code to be executed if the condition is True.  { a++; document.write("in if statement of a is:"+a+"<br>") break; //Break :- when the loop iterates for first time, the value of i=10, the if statement result will be false, so the else condition is executed.   //loop iterates again now i=15; if condition result will be 'True' and loop breaks.      //you can also use 'Continue'      //Continue:-when the loop iterate for the first time the value of i=10, the if statement result will be false, so the else condition 2 is implemented.    //loop iterates again now i=15; if condition result will be 'True' and the code ...

//Relation Operator

Relation Operator   <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> </title> </head> <body> <script type="text/javascript"> var a = 21; var b = 10; //equal to if (a == b) // (a=21 == b=10) is False; Therefore a is not equal to b.            //the two given values are equal to each other then result will be True, Otherwise it returns False. { document.write(" a is equal to b "+"<br>"); }  else  { document.write(" a is not equal to b"+"<br>"); // document.write() use for print line. } //grater than if (a > b) //(a=21 > b=10) is True; Therefore a is grater than b.             //the first value is grater than the second value then result will be True, Otherwise it returns False. { document.write("a is greater than b"+"<br>"); }  else  { document.write("a is not greater than b...

//Logical Operator

Logical Operator  <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script type="text/javascript"> var a = 50; var b = 30; //Logical AND        //we use also  Logical NOT if (!((a > b) && (a == b))) // !(a=50 > b=30) is False && (a=50 != b=30) is True; Therefore this statement is False.                                    // when both statement are True then result will be True.                                   // '!'not is True statement consider False and False statement consider to True. { document.write("this statement is true <br>"); } else { document.write("this statement is false <br>"); // document.write() use for print line....

//Bitwise Operator

Bitwise Operator <!DOCTYPE html> <html> <head> <title></title> </head> <body> <script type="text/javascript"> var a = 50; //00110010 in binary. var b = 30; //00011110 in binary. var c = 0; var d = 0; var e = 0; var f = 0; var g = 0; var h = 0; //Bitwise AND c = a & b; // 00110010 & 00011110 = 00010010 i.e means is '18'. document.write("the value is: "+c+"<br>"); // <br> use for linebreake //Bitwise OR d = a | b; // 00110010 | 00011110 = 00111110 i.e means is '62'. document.write("the value is: "+d+"<br>"); // document.write() use for print line. //Bitwise Exclusive XOR e = a ^ b;  // 00110010 ^ 00011110 = 00101100 i.e means is '44'. document.write("the value is: "+e+"<br>");// +e+ is used to indicate which value should be print. //Bitwise Complement f = ~a; // -(50+1)= i.e means is '-51'. document.write(...

//Assignment Operator

Assignment Operator    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script type="text/javascript"> var a = 31; var c = 9; //Add AND  c += a; // c = c + a; 9 + 31 = 40; document.write("the addition of c is :"+c+"<br>"); // document.write() use for print line. //Subtract ANd c -= a; // c = c - a; 40 - 31 = 9;  document.write("the substraction of c is :"+c+"<br>");// <br> use for linebreake. //Multiply AND c *= a; // c = c * a; 9 * 31 = 279;  document.write("the multiplication of c is :"+c+"<br>"); //Division c /= a; // c = c / a; 279 / 31 = 9;  document.write("the division of c is :"+c+"<br>"); //Mod AND c %= a; // c = c % a; 9 % 9 = 9;  document.write("the modulus of c is :"+c+"<br>"); </script> </body> </html> // Execu...

//Arthmatic Operator

Arthmatic Operator <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script type="text/javascript"> var a= 21; //Variable def var b= 10; var c; //Addition c = a + b; document.write("the addition is :"+c+"<br>"); // document.write() use for print line. //Subtraction c = a - b; document.write("the subtraction is :"+c+"<br>"); // +c+ is used to indicate which value should be print. //Multiplication c = a * b; document.write("the multipliation is :"+c+"<br>");// <br> use for linebreake //Division c = a / b; document.write("the divition is :"+c+"<br>"); //Modulus c = a % b; document.write("the modulus is :"+c+"<br>"); </script> </body> </html> // Execute //Output  /* the addition is :31 the subtraction is :11 the multipliation i...