-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24e66d7
commit 0498e62
Showing
18 changed files
with
485 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<html> | ||
<head> | ||
<script> | ||
// Add 2 decimal numbers | ||
var a = 2.3; | ||
var b = 3.3; | ||
console.log(a+b); | ||
|
||
// Or | ||
|
||
var c = 2.0; | ||
var d = 4.0; | ||
console.log((c+d).toFixed(1)) | ||
</script> | ||
</head> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<html> | ||
|
||
<head> | ||
<script> | ||
// Sorting | ||
|
||
// let arrN = [2, 9, 3, 7, 20, 5]; | ||
// let arrS = ['Jan', 'Feb', 'December', 'July', 'April']; | ||
|
||
// arrN.sort((a,b)=> a-9); | ||
// arrN.sort(function cmp(a,b){ | ||
|
||
// }); | ||
// console.log(arrN); | ||
|
||
// arrS.sort(); | ||
// arrS.reverse(); | ||
// console.log(arrS); | ||
|
||
//Object Creation using Object Constructor | ||
|
||
function Objt(a, b, c, d) { | ||
this['Objt1'] = a; | ||
this.Objt2 = b; | ||
this.Objt3 = c; | ||
this.Objt4 = d; | ||
|
||
} | ||
Objt.ky = 5; | ||
|
||
let vl = new Objt(1, 4, 6, 2); | ||
console.log(vl); | ||
|
||
console.log(this); | ||
|
||
console.log(vl.ky); | ||
|
||
</script> | ||
</head> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<html> | ||
|
||
<head> | ||
<script> | ||
// Sorting Method 1 | ||
|
||
let arrN = [2, 9, 3, 7, 20, 5]; | ||
|
||
function cmp(a, b) { | ||
return a < b ? -1 : a > 2 && a < 6 ? -1 : 0; | ||
} | ||
|
||
console.log(arrN.sort(cmp)); | ||
|
||
|
||
// Sorting Method 2 | ||
|
||
let arrN2 = [2, 9, 3, 7, 20, 5]; | ||
|
||
arrN2.sort((a,b)=>a-b); | ||
|
||
let n = Math.ceil(arrN2.length/2); | ||
|
||
let arrSplcd = arrN2.splice(0,n); | ||
|
||
let arrSplcd2 = arrN2.splice(n,arrN2.length); | ||
|
||
arrSplcd.reverse(); | ||
|
||
let mrgdArr = [...arrSplcd,...arrN2]; | ||
|
||
console.log(mrgdArr); | ||
|
||
|
||
|
||
|
||
|
||
</script> | ||
</head> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<html> | ||
|
||
<head> | ||
<script> | ||
// Bind, Call, Apply | ||
|
||
let Objt = { | ||
'key1':'abc', | ||
'key2': 2, | ||
'key3':function(a,b){ | ||
// return this.key1 +' '+ this.key2 + ' ' + a + ' ' + b; | ||
return `${this.key1} ${this.key2} ${a} ${b} word`; | ||
} | ||
} | ||
|
||
let Objt2 = { | ||
'key1': 'dce', | ||
'key2': 5 | ||
} | ||
|
||
|
||
let Objtv = Objt.key3.apply(Objt2,[6,8]); | ||
|
||
// let Objt2int = new Objt2(); | ||
|
||
// let Objtint = new Objt(Objt2int); | ||
|
||
|
||
|
||
console.log(Objtv); | ||
|
||
|
||
|
||
|
||
</script> | ||
</head> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<html> | ||
|
||
<head> | ||
<script> | ||
// Class | ||
|
||
|
||
class fnc{ | ||
constructor(name,age){ | ||
this.name = name; | ||
this.age = age; | ||
} | ||
|
||
fn(){ | ||
let r = 30/2; | ||
console.log(r); | ||
} | ||
} | ||
|
||
let oFnc = new fnc('sa',100); | ||
|
||
oFnc.fn(); | ||
|
||
|
||
|
||
</script> | ||
</head> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
<html> | ||
|
||
<head> | ||
|
||
<script type="module"> | ||
//Modules | ||
|
||
let v1 = 5; | ||
let v2 = 10; | ||
|
||
export { v1, v2 } | ||
|
||
|
||
</script> | ||
</head> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { v1, v2 } from './new14.js' | ||
|
||
console.log(v1); | ||
console.log(v2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<html> | ||
|
||
<head> | ||
|
||
<script type="module"> | ||
|
||
// Import Export | ||
|
||
import { v1, v2 } from './new14.html' | ||
|
||
console.log(v1); | ||
console.log(v2); | ||
|
||
|
||
</script> | ||
</head> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<html> | ||
|
||
<head> | ||
|
||
<script> | ||
//Error Handling | ||
|
||
let v1 = 5; | ||
let v2 = 6; | ||
|
||
let sum = () => v1 + v2; | ||
|
||
try { | ||
if (sum() === 11) { | ||
throw { | ||
'name': 'abc', | ||
'message': '11 is an error' | ||
}; | ||
|
||
} | ||
// sum(); | ||
|
||
} | ||
|
||
catch (err) { | ||
console.log(err); | ||
console.log(err.name); | ||
console.log(err.message); | ||
} | ||
|
||
finally { | ||
console.log('Code Executed'); | ||
} | ||
|
||
</script> | ||
|
||
</head> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
<head> | ||
<script> | ||
// Multiply string by a number | ||
var a = '34'; | ||
var b = 40; | ||
console.log(a*b); | ||
</script> | ||
</head> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<html> | ||
|
||
<head> | ||
<script> | ||
// Compare number and print if it is a decimal | ||
var n = 13.2; | ||
|
||
if ((n - Math.floor(n)) !== 0) | ||
console.log(n + ' has a decimal place.'); | ||
else | ||
console.log(n + ' is a whole number.'); | ||
|
||
//OR | ||
var m = 17.8; | ||
|
||
if (Math.floor(m) !== m) | ||
console.log(m + ' has a decimal place.'); | ||
else | ||
console.log(m + ' is a whole number.'); | ||
|
||
</script> | ||
</head> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<html> | ||
|
||
<head> | ||
<script> | ||
// Array to add & remove elements | ||
|
||
const items = ['table','chair','desk']; | ||
console.log(items); | ||
|
||
// items.pop(); | ||
// console.log(items); | ||
|
||
// items.push('bottle'); | ||
// console.log(items); | ||
|
||
items.unshift('umbrella'); | ||
console.log(items); | ||
|
||
items.shift(); | ||
console.log(items); | ||
|
||
// items.splice(1,1,'basket'); | ||
// console.log(items); | ||
|
||
</script> | ||
</head> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<html> | ||
|
||
<head> | ||
<script> | ||
// Randomly add elements to an array | ||
|
||
const Ritems = []; | ||
const items = ['table', 'chair', 'desk', 'bottle', 'pen', 'pencil']; | ||
|
||
while (items.length) { | ||
Ritems.splice(Math.floor(Math.random() * (Ritems.length + 1)), 0, items.pop()); | ||
} | ||
|
||
console.log(Ritems); | ||
|
||
</script> | ||
</head> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<html> | ||
|
||
<head> | ||
<script> | ||
|
||
let obj = { | ||
"key1": 123, | ||
"key2": true, | ||
"key3": `abc` | ||
} | ||
|
||
|
||
let arrObj = Object.entries(obj); | ||
|
||
// arrObj[1].map((curVal)=> console.log(curVal)); | ||
|
||
console.log(arrObj); | ||
|
||
// arrObj.map(function (curVal, index, arr){ | ||
// for (i=0; i<2; i++){ | ||
// console.log(arrObj[index][i]); | ||
// } | ||
// }) | ||
|
||
|
||
arrObj.map(function(curVal,index,arr){ | ||
curVal.map(function(cuVal){ | ||
console.log(cuVal); | ||
} | ||
) | ||
}) | ||
|
||
// for (i = 0; i < 2; i++) { | ||
// for (j = 0; j < 2; j++) { | ||
// console.log(arrObj[i][j]); | ||
// } | ||
// } | ||
|
||
|
||
|
||
</script> | ||
</head> | ||
|
||
</html> |
Oops, something went wrong.