Skip to content

Commit 4105e3d

Browse files
committed
Adding File
1 parent 0464346 commit 4105e3d

File tree

121 files changed

+4662
-0
lines changed

Some content is hidden

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

121 files changed

+4662
-0
lines changed

1 Output/index.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
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>JavaScript Display Possibilities</title>
9+
</head>
10+
11+
<body>
12+
<h1 id="demo">This is ID</h1>
13+
14+
<h2 class="paragraph">This is Class</h2>
15+
16+
<h2>This is Element Tag</h2>
17+
18+
<button onclick="window.print()">Print This Page</button><br>
19+
20+
<script src="output.js"></script>
21+
</body>
22+
23+
</html>

1 Output/output.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
document.getElementById('demo').innerHTML = "Example of Inner HTML in ID";
2+
document.getElementsByClassName("paragraph")[0].innerHTML = "Example of Inner HTML in Class Name";
3+
document.getElementsByTagName("h2")[1].innerHTML = "Example of Inner HTML in Tag Name";
4+
document.write("Example of Write");
5+
6+
//window.alert("This is Window Alert");
7+
alert("This is Alert");
8+
confirm("This is Confirm");
9+
prompt("This is Prompt");
10+
11+
//window.print();
12+
13+
console.time("This is Your Console Time");
14+
15+
console.log("This is Console Log");
16+
console.info("This is Console Info");
17+
console.warn("This is Console Warning");
18+
console.error("This is Console Error");
19+
20+
console.timeEnd('This is Your Console Time');
21+
22+
const person = {
23+
firstName: "Suraj",
24+
lastName: "Patel",
25+
age: 25,
26+
course: 'MCA'
27+
};
28+
29+
console.time("This is Your Console Time Log");
30+
31+
console.log(person);
32+
console.table(person);
33+
34+
console.timeLog("This is Your Console Time Log");
35+
36+
console.assert(5 < 4, 'This is not possible');
37+
38+
console.timeEnd("This is Your Console Time Log");
39+
40+
//console.clear();

10 Loops/index.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
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>JavaScript Loops</title>
9+
</head>
10+
11+
<body>
12+
<script src="loops.js"></script>
13+
</body>
14+
15+
</html>

10 Loops/loops.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// JavaScript Loops
2+
3+
// An array with some elements
4+
let marks = [69, 85, 94, 76, 57];
5+
let fruits = ["Apple", "Banana", "Mango", "Orange", "Papaya"];
6+
// An object with some properties
7+
let person = { "name": "Suraj", "surname": "Patel", "age": "25" };
8+
9+
// The For Loop
10+
console.log(" - - - - - - - - - - The For Loop - - - - - - - - - - ");
11+
for (let j = 0; j < marks.length; j++) {
12+
console.log(marks[j]);
13+
}
14+
15+
// The For In Loop
16+
console.log(" - - - - - - - - - - The For In Loop - - - - - - - - - - ");
17+
// Loop through all the elements in the array
18+
console.log(" = = = = = Loop through all the elements in the array = = = = = ");
19+
for (let f in fruits) {
20+
console.log(fruits[f]);
21+
}
22+
// Loop through all the properties in the object
23+
console.log(" = = = = = Loop through all the properties in the object = = = = = ");
24+
for (let properties in person) {
25+
console.log(properties, person[properties]);
26+
}
27+
28+
// The For Of Loop
29+
console.log(" - - - - - - - - - - The For Of Loop - - - - - - - - - - ");
30+
// Iterating over array
31+
console.log(" = = = = = Iterating over array = = = = = ");
32+
for (let f of fruits) {
33+
console.log(f);
34+
}
35+
// Iterating over string
36+
console.log(" = = = = = Iterating over string = = = = = ");
37+
let car = "Tesla";
38+
for (let c of car) {
39+
console.log(c);
40+
}
41+
42+
// The Array.forEach() Loop
43+
console.log(" - - - - - - - - - - The Array.forEach() Loop - - - - - - - - - - ");
44+
fruits.forEach((itemValue) => {
45+
console.log(itemValue);
46+
})
47+
48+
// The Array.forEach() Loop with arguments
49+
console.log(" - - - - - - - - - - The Array.forEach() Loop with arguments - - - - - - - - - - ");
50+
fruits.forEach(function (itemValue, itemIndex, arrayItself) {
51+
console.log(itemValue, " : ", itemIndex, " : ", arrayItself);
52+
})
53+
54+
// The While Loop
55+
console.log(" - - - - - - - - - - The While Loop - - - - - - - - - - ");
56+
let f = 0;
57+
while (f < fruits.length) {
58+
console.log(fruits[f]);
59+
f++;
60+
}
61+
62+
// The Do While Loop
63+
console.log(" - - - - - - - - - - The Do While Loop - - - - - - - - - - ");
64+
f = 0;
65+
do {
66+
console.log(fruits[f]);
67+
f++;
68+
} while (f < fruits.length);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Break Statement
2+
console.log(" - - - - - - - - - - Break Statement - - - - - - - - - - ");
3+
for (let b = 0; b < 5; b++) {
4+
if (b == 3) { break; }
5+
console.log(b);
6+
}
7+
8+
// Continue Statement
9+
console.log(" - - - - - - - - - - Continue Statement - - - - - - - - - - ");
10+
for (let c = 0; c < 5; c++) {
11+
if (c == 2) { continue; }
12+
console.log(c);
13+
}

11 Break and Continue/index.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
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>JavaScript Break and Continue</title>
9+
</head>
10+
11+
<body>
12+
13+
<script src="break and continue.js"></script>
14+
</body>
15+
16+
</html>

12 Array Methods/array methods.js

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// = = = Array Methods = = =
2+
console.log(" - - - - - - - - - - Array Methods - - - - - - - - - - ");
3+
4+
let dryFruits = ["Almonds", "Apricot", "Pistachio", "Raisins", "Walnut"];
5+
let fruits = ['Apple', 'Banana', 'Orange', 'Papaya', 'Grape', 'Mango'];
6+
7+
console.log(dryFruits.length); //Find array length
8+
9+
let dryFruitsString = dryFruits.toString(); //Converts an array to a string of (comma separated) array values
10+
console.log(dryFruitsString);
11+
12+
let dryFruitsJoin = dryFruits.join(" - "); //Joins all array elements into a string
13+
console.log(dryFruitsJoin);
14+
15+
let dryFruitsSplit = dryFruitsJoin.split(" - "); //Split a string to an array
16+
console.log(dryFruitsSplit);
17+
18+
let removeLast = dryFruits.pop(); //Removes the last element from an array
19+
console.log(removeLast); //Returns the value that was "popped out"
20+
21+
let addLast = dryFruits.push("Peanuts"); //Adds a new element to an array (at the end)
22+
console.log(addLast); //Return the new array length
23+
24+
let removeFirst = dryFruits.shift(); //Removes the first element from and array
25+
console.log(removeFirst); //Returns the value that was "shifted out"
26+
27+
let addFirst = dryFruits.unshift("Saffron"); //Adds a new element to an array (at the beginning)
28+
console.log(addFirst); //Returns the new array length
29+
30+
console.log(dryFruits); //Print Array
31+
32+
33+
34+
console.log(" - - - - - - - - - - Array.isArray() - - - - - - - - - - ");
35+
console.log(Array.isArray(dryFruits));
36+
37+
console.log(" - - - - - - - - - - indexOf() - - - - - - - - - - ");
38+
console.log(dryFruits.indexOf('Raisins'));
39+
40+
console.log(" - - - - - - - - - - concat() - - - - - - - - - - ");
41+
let mixFruits = dryFruits.concat(fruits);
42+
console.log("Mix Fruits (Concatenation Array) : ", mixFruits);
43+
console.log("Dry Fruits : ", dryFruits);
44+
console.log("Fruits : ", fruits);
45+
46+
console.log(" - - - - - - - - - - sort() - - - - - - - - - - ");
47+
let mixFruitsSort = mixFruits.sort();
48+
console.log("Mix Fruits (Sort Array) : ", mixFruitsSort);
49+
console.log("Mix Fruits : ", mixFruits);
50+
51+
console.log(" - - - - - - - - - - reverse() - - - - - - - - - - ");
52+
let mixFruitsReverse = mixFruits.reverse();
53+
console.log("Mix Fruits (Reverse Array) : ", mixFruitsReverse);
54+
console.log("Mix Fruits : ", mixFruits);
55+
56+
console.log(" - - - - - - - - - - splice() - - - - - - - - - - ");
57+
let spliceFruits = mixFruits.splice(2, 5);
58+
console.log("Mix Fruits (Splice Array) : ", spliceFruits);
59+
console.log("Mix Fruits : ", mixFruits);
60+

12 Array Methods/index.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
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>JavaScript Array Methods</title>
9+
</head>
10+
11+
<body>
12+
13+
<script src="array methods.js"></script>
14+
</body>
15+
16+
</html>

13 String Methods/index.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
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>JavaScript String Methods</title>
9+
</head>
10+
11+
<body>
12+
13+
<script src="string methods.js"></script>
14+
</body>
15+
16+
</html>

13 String Methods/string methods.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// = = = String Methods = = =
2+
let colorSentence = " color Red looks brighter than color Blue. ";
3+
let textPadding = "5";
4+
console.log(colorSentence.length); //Find String length
5+
console.log(colorSentence.indexOf("color")); //Find First Index
6+
console.log(colorSentence.lastIndexOf("color")); //Find Last Index
7+
console.log(colorSentence.toLowerCase()); //Converting a String to Lowercase
8+
console.log(colorSentence.toUpperCase()); //Converting a String to Uppercase
9+
console.log(colorSentence.trim()); //Removes whitespace from both sides of a string
10+
console.log(textPadding.padStart(4, 0)); //String Padding Start "0005"
11+
console.log(textPadding.padEnd(4, 0)); //String Padding End "5000"
12+
let colorReplace = colorSentence.replace("Blue", "Green"); //Replace String
13+
console.log(colorReplace, colorSentence); //Print New Sentence and Old Sentence
14+
console.log(colorSentence.slice(3, 12)); //Extracts a part of a string and returns the extracted part in a new string
15+
console.log(colorSentence.substring(3, 12)); //Similar to slice(). The different is that substring() cannot accept negative indexes
16+
console.log(colorSentence.split(' ')); //Converting a string to an array
17+
console.log(colorSentence.charAt(9)); //Returns the character at a specified index in a string
18+
console.log(colorSentence.charCodeAt(9)); //Returns the ASCII character code at a specified index in a string
19+
console.log(colorSentence[9]); //Similar to charAt()
20+
console.log(colorSentence.startsWith(' color')); //The startWith() method returns true if a string start with a specified string. Otherwise it returns false
21+
console.log(colorSentence.includes('Red')); //The includes() method returns true if a string contains a specified string. Otherwise it returns false
22+
console.log(colorSentence.endsWith('Blue. ')); //The endWith() method returns true if a string ends with a specified string. Otherwise it returns false
23+
console.log(colorSentence.concat('You are Right.')); //Joins two or more strings
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// = = = Date and Time Method = = =
2+
let currentDate = new Date();
3+
console.log(Date());
4+
console.log(currentDate);
5+
console.log(currentDate.getHours()); //Display the number of hours into the day (0-23)
6+
console.log(currentDate.getMinutes()); //Display the number of minutes into the hour (0-59)
7+
console.log(currentDate.getSeconds()); //Display the seconds into the minute (0-59)
8+
console.log(currentDate.getMilliseconds()); //Display the number of milliseconds into second (0-999)
9+
console.log(currentDate.getFullYear()); //Display the full year (four digits)
10+
console.log(currentDate.getMonth()); //Display the number of months into the year (0-11)
11+
console.log(currentDate.getDate()); //Display the day of the month
12+
console.log(currentDate.getDay()); //Display the number of days into the week (0-6)
13+
14+
let otherDate = new Date('2004-2-29 9:45:25');
15+
// otherDate = new Date('Feb 29 2004');
16+
// otherDate = new Date('2/29/2004');
17+
console.log(otherDate);
18+
otherDate.setDate(15)
19+
otherDate.setMonth(6)
20+
otherDate.setFullYear(2008)
21+
console.log(otherDate);

14 Date and Time Methods/index.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
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>JavaScript Date and Time Methods</title>
9+
</head>
10+
11+
<body>
12+
13+
<script src="date and time methods.js"></script>
14+
</body>
15+
16+
</html>

15 Math Methods/index.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
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>JavaScript Math Methods</title>
9+
</head>
10+
11+
<body>
12+
13+
<script src="math methods.js"></script>
14+
</body>
15+
16+
</html>

15 Math Methods/math methods.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//Math Object
2+
console.log(Math);
3+
console.log(Math.E); //Return Euler's number
4+
console.log(Math.PI); //Return PI
5+
6+
//Math Methods
7+
let check = 45.4;
8+
console.log(Math.round(check)); //Return 'check' rounded to its nearest integer
9+
console.log(Math.ceil(check)); //Return 'check' rounded up to its nearest integer
10+
console.log(Math.floor(check)); //Return 'check' rounded down to its nearest integer
11+
console.log(Math.trunc(check)); //Return the integer part of 'check'
12+
console.log(Math.sign(check)); //Return if 'check' is negative, null or positive
13+
console.log(Math.sqrt(64)); //Return the square root of '64'
14+
console.log(Math.pow(5, 3)); //Return the value of '5' to the power of '3'
15+
console.log(Math.abs(-45.8)); //Return the absolute (positive) value of '-45.8'
16+
console.log(Math.min(9, 5, 0, -8,)); //Return the lowest value in a list of argument
17+
console.log(Math.max(9, 5, 0, -8,)); //Return the highest value in a list of argument
18+
console.log(Math.random()); //Return a random number between 0 (inclusive), and 1 (exclusive)

0 commit comments

Comments
 (0)