Skip to content

Commit 410ef37

Browse files
committed
adding js files.js
0 parents  commit 410ef37

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2203
-0
lines changed

1-LJeVeJKqiZ6vlsHKgRdrkw.png

168 KB
Loading

Arithmatic operators.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var a=5;
2+
var b=9;
3+
4+
c=a+b;
5+
d=a-b;
6+
e=a*b;
7+
f=a/b;
8+
g=a**b;
9+
h=a^b;
10+
i=a%b;
11+
12+
console.log(c);
13+
console.log(d);
14+
console.log(e);
15+
console.log(f);
16+
console.log(g);
17+
console.log(h);
18+
console.log(i);

Comparison operators.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var a=4;
2+
var b="4";
3+
var c=3;
4+
var d=11;
5+
console.log(a==b); //true
6+
console.log(a===b); // false
7+
console.log(a>c); //true
8+
console.log(c>=d); // false
9+
console.log(c!=d); // true

Console.log.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("node working");

IMG_20191119_015008.jpg

70.8 KB
Loading

IMG_20200722_172439 (1).jpg

30.9 KB
Loading

alert.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
alert("Js excuted");
2+
3+
var firstnum = 78,secondnum=45;
4+
var div=firstnum/secondnum;
5+
alert(div);
6+
7+
8+
Array[5]={a,e,i,o,u};
9+
alert(Array[1]);

anohter.html

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<html>
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<title>me.com</title>
9+
</head>
10+
<body>
11+
<p id="demo">
12+
your function of js appeared here ......
13+
</p>
14+
<script src="classes.js"></script>
15+
<div id="wrapper">JavaScript is fun!</div>
16+
<input type="text" name="myNum1" onkeypress="numCheck()">
17+
<input type="text" name="myNum2" onkeypress="numCheck2()">
18+
<script>
19+
function numCheck() {
20+
message("Number: " + !isNaN(event.key));
21+
return !isNaN(event.key);
22+
}
23+
function numCheck2() {
24+
message("Not a number: " + isNaN(event.key));
25+
return isNaN(event.key);
26+
}
27+
function message(m) {
28+
document.getElementById('wrapper').innerHTML = m;
29+
}
30+
</script>
31+
<div id = "fit"></div>
32+
33+
<form action="anotherpage.html" method="get" onsubmit="return msg()">
34+
<input type="text" id="fn" placeholder="fname" name="fname" />
35+
<input type="text" id = "ln" placeholder="lname" name="lname" />
36+
<input type="text" id = "age" placeholder="age" name="age" />
37+
<input type="submit" value="submit" />
38+
39+
</form>
40+
<script>
41+
42+
</script>
43+
<h1>
44+
go backward !
45+
<input type="button" value="Click" onClick="history.back();">
46+
you directed to the next Page jani love you</h1>
47+
48+
<form onsubmit="return checkpassword();">
49+
enter a password<br>
50+
<input type="text" id="f1">
51+
<input type="submit" value="submit Form">
52+
</form>
53+
54+
</body>
55+
</html>
56+
</html>

anotherpage.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<html lang="en">
2+
<head>
3+
<meta charset="UTF-8">
4+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
<div id = "fit"></div>
10+
<script>
11+
/** let q = window.location.search;
12+
let params = new URLSearchParams(q);
13+
let name = params.get("name");
14+
console.log(name);
15+
welcome("welcome here");
16+
function welcome(m){
17+
document.getElementById("those").innerHTML = m;
18+
}*/
19+
function valFrom(){
20+
var check = event.target.children;
21+
if(check.fname.value == " "){
22+
msg("need a first name !");
23+
return false;
24+
}
25+
if(check.lname.value == " "){
26+
msg("need a last name !");
27+
return false;
28+
}
29+
if(check.age.value == " "){
30+
msg("need an age input !");
31+
return false;
32+
}
33+
return true;
34+
}
35+
function msg(s){
36+
document.getElementById("fit").innerHTML = s;
37+
}
38+
</script>
39+
</body>
40+
</html>

arr splice shift unshift slice.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var arr=["some","People","have","curly","brown","hair"];
2+
3+
arr.splice(2,2,"must"); //adding element at index 2 removing index 2 past element.
4+
5+
console.log(arr);
6+
arr.shift(); // remove first element in the array
7+
console.log(arr);
8+
9+
arr.unshift("yo","man"); // add elements at the beginning of the array
10+
console.log(arr);

array reverse and sort.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var num=[12,1,55,05,65,33,14,0,17];
2+
console.log(num);
3+
4+
num=num.sort();
5+
console.log(num); //  [0, 1, 12, 14, 17, 33, 5, 55, 65]
6+
7+
console.log(num.reverse()); // [65, 55, 5, 33, 17, 14, 12, 1, 0]
8+

array with loops.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
var arr=["same","casey","Dewayne","Rexha"];
2+
for(var i=0;i<arr.length;i++){
3+
console.log(arr[i]); // printing array values one by one
4+
}
5+
6+
7+
var arr2=[45,44,45,96,32,1,2,47,58,56,22];
8+
for(var i2=0;i2<arr2.length;i2++){
9+
arr2[i2]=arr2[i2]*2;
10+
}
11+
for(var j=0;j<arr2.length;j++){
12+
console.log(arr2[j]); // printing array values one by one
13+
}
14+
15+
16+
var arr2=[45,44,45,96,32,1,2,47,58,56,22];
17+
for(var i2=0;i2<arr2.length;i2++){
18+
arr2[i2]=arr2[i2]*2;
19+
}
20+
for(var j=0;j<arr2.length;j++){
21+
console.log(arr2[j]); // printing array values one by one
22+
}
23+
24+
// check a value present in an array or not searching a number
25+
26+
var arrayy=[54,44,28,4,6,2,1,3,6,47];
27+
28+
var searchnum=parseInt(prompt("Enter a number to check "));
29+
var found=false;
30+
for(var f=0;f<arrayy.length;f++){
31+
if(arrayy[f]===searchnum){
32+
console.log("entered number : "+searchnum+" found at index : "+f);
33+
found=true;
34+
break;
35+
}
36+
}
37+
if(found==false){
38+
console.log("your entered value is not found !");
39+
}
40+
41+
42+
43+

arrays.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
var array=[45,33,12,44,11]; //range 0 to -1
2+
var menu=["sandwich","pizza","french fries","burger"];
3+
var bools=[true,false,true,true,false];
4+
var mixed=["hello",45.2,"#"];
5+
var mixed2=[{sequnce : "mike"},{force : "afterwards 56 "}];
6+
console.log(array[2]); // accessing array elements
7+
console.log(menu);
8+
console.log(bools[3]);
9+
console.log(mixed.length);
10+
console.log(mixed2[1]);
11+
console.log(mixed2[3]); // undefined since the value is not at the given index
12+
13+
// add update elements using index
14+
15+
var adding=[];
16+
17+
adding[0]="a";
18+
adding[1]="e";
19+
adding[2]="i";
20+
adding[3]="o";
21+
22+
console.log(adding); // all arrays can printed
23+
console.log(adding=>2);
24+
console.log(adding[6]); // undefined
25+
adding[11]="se";
26+
console.log(adding+" "+adding.length); // directly adding value jumping empty indexes.
27+
28+
//updating an
29+
adding[2]="rt";
30+
console.log(adding);
31+
32+
33+
// array push
34+
35+
var pushing=[];
36+
37+
pushing.push(31);
38+
pushing.push("hexadecimal");
39+
pushing.push("somewhat","exactly");
40+
console.log(pushing);
41+
42+
//array user input , order shop
43+
44+
45+
do{
46+
var order=prompt("what do you want sir select category drink or meal ");
47+
var i;
48+
var drink_cost=32;
49+
var meal_cost=78;
50+
var items_purchased=[];
51+
var howmany=parseInt(prompt("enter quantity"));
52+
var orderagain=prompt("do you want to place more orders: say yes or no");
53+
switch(order){
54+
case "drink":
55+
total_paybill=drink_cost*howmany;
56+
console.log("your paybill is : "+total_paybill+" each costs : "+drink_cost+"$");
57+
items_purchased.push(order);
58+
break;
59+
case "meal":
60+
total_paybill=meal_cost*howmany;
61+
console.log("your paybill is : "+total_paybill+" each costs : "+meal_cost+"$");
62+
items_purchased.push(order);
63+
break;
64+
}
65+
66+
}while(orderagain=="yes");
67+
console.log(items_purchased);
68+
69+
70+
71+

assignment operator.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var a=5;
2+
var b=9;
3+
a*=b;
4+
b-=a;
5+
6+
7+
console.log(a);
8+
console.log(b);

async await.js

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/**
2+
* // EXAMPLE 01
3+
function greet(x){ // a first function is made
4+
const myprom=new Promise(resolve =>{ // adding promise with set time out function of 2 seconds delay
5+
setTimeout(() => {
6+
resolve("Something will happen as : "+x); // the settimeout body executes afet 2 seconds delay
7+
}, 2000);
8+
});
9+
return myprom // promise object name return
10+
}
11+
12+
async function greetcatcher(x){ // async funtion
13+
const talkout= await greet(x); // greet catcher waits for timout of 2 seconds held off to show message inside promise
14+
console.log(talkout); // message under await , where await waits 2 seconds for first function called.
15+
}
16+
greetcatcher("function called after 2 sec delay !"); // function message print run after 2 seconds.
17+
console.log(1+"delay break");
18+
greetcatcher("function called after 2 sec delay second time !");
19+
console.log(2+"delay break");
20+
greetcatcher("function called after 2 sec delay third time !");
21+
console.log(3+"delay break");
22+
* */
23+
24+
25+
/** // EXAMPLE 02
26+
* async function myDisplay() {
27+
let myPromise = new Promise(function(resolve) {
28+
setTimeout(() => {
29+
resolve("I love You !!");
30+
31+
}, 3000);
32+
});
33+
document.getElementById("demo").innerHTML = await myPromise;
34+
}
35+
36+
myDisplay();
37+
38+
*
39+
*/
40+
41+
42+
/**
43+
// THROUGH AJAX CALLOUT OTHER EXTERNAL/INternal PAGES alongwith async and promise , await
44+
async function getFile(){
45+
let promi=new Promise(function (resolve,reject){
46+
let req = new XMLHttpRequest(); // ajax calling
47+
req.open("GET","index.html"); // giving path and operation to perform on triggered file here open file.
48+
req.onload = function(){
49+
if(req.status == 200){
50+
resolve(req.response);
51+
}
52+
else{
53+
reject("file not availble in the triggered directory !");
54+
}
55+
56+
};
57+
req.send();
58+
});
59+
document.getElementById("demo").innerHTML = await promi;
60+
}
61+
getFile(); //callout whole function
62+
*
63+
*
64+
*/
65+
66+
67+
const passtypes =["abc","adx"];
68+
69+
function checkout(pass){
70+
return passtypes.includes(pass);
71+
}
72+
function login(password){
73+
return new Promise((resolve,reject) => {
74+
if(checkout(password)){
75+
resolve({
76+
status : true ,
77+
show : "Logged in sucessfully"
78+
});
79+
}
80+
else{
81+
reject({
82+
status : false
83+
});
84+
}
85+
});
86+
}
87+
function checkout2(pass){
88+
login(pass)
89+
.then(token => {
90+
console.log("Approve:");
91+
console.log(token);
92+
})
93+
.catch(value => {
94+
console.log("Reject:");
95+
console.log(value);
96+
})
97+
}
98+
//var ask =prompt("enter password :");
99+
const x = document.getElementById("ok");
100+
var ano = x.value;
101+
//checkout2(ano);
102+
103+
104+
105+
106+
107+

0 commit comments

Comments
 (0)