The most viewed posts

Registry Reviver

How to clean up Windows Computer

About Desktop Icons in Windows Computer

How to make a computer secure and run faster

Driver Booster

Myanmar font and keyboard for Windows

CCleaner

Web Development Services

Advanced System Care

some (JavaScript Array Method)

The most viewed items

Desktop Hard Disk

Dell Inspiron 5559

HP ProBook 430

SONY Playstation Portable

Laptop RAM

External Hard Disk

Laptop

ZilaStar ICT Nov 16 2021, 19:51:24

Foreach Loop (JS Arrays)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo">forEach Loop</p>
<script>
var cities, text;
cities = ["Yangon", "Mandalay", "Naypyidaw", "Meikhtila"];

text = "<ul>";
cities.forEach(jsFunction);
text+= "</ul>";

function jsFunction(value){
text += "<li>" + value + "</li>";
}

document.getElementById("demo").innerHTML = text;

</script>
</body>
</html>


ZilaStar ICT Oct 30 2021, 19:50:56

Creating the Array (JS Arrays)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo1"></p>
<p id = "demo2"></p>
<script>

//good habit in crating array
var a = ["aaa", "bbb", "ccc", "ddd"];
document.getElementById("demo1").innerHTML = a;

//bad habit in creating array
var b = new Array("aaa", "bbb", "ccc", "ddd");
document.getElementById("demo2").innerHTML = b;
</script>
</body>
</html>


ZilaStar ICT Oct 13 2021, 19:50:22

Array Elements (JS Arrays)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo1"></p>
<p id = "demo2"></p>
<script>

var a = ["aaa", "bbb", "ccc", "ddd"];
a[0] = "eee";
document.getElementById("demo1").innerHTML = a;


var b = new Array("aaa", "bbb", "ccc", "ddd");
document.getElementById("demo2").innerHTML = b[2];
</script>
</body>
</html>


ZilaStar ICT Sep 29 2021, 19:49:31

Adding Array Element (JS Arrays)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo">forEach Loop</p>
<script>
var cities, text;
cities = ["Yangon", "Mandalay", "Naypyidaw", "Meikhtila"];

text = "<ul>";
cities.forEach(jsFunction);
text+= "</ul>";

function jsFunction(value){
text += "<li>" + value + "</li>";
}

document.getElementById("demo").innerHTML = text;

</script>
</body>
</html>


ZilaStar ICT Sep 05 2021, 19:48:42

unshift (JavaScript Array Method)

const tnwNames = ["Moe", "Soe", "Noe", "Mya"];
function tnwFun1(){
document.getElementById("demo").innerHTML = tnwNames.join(", ");
}

function tnwFun2(){
document.getElementById("demo").innerHTML = "The original array is : " + tnwNames.join(", ");
let tnwNewvalue = document.getElementById("newname").value;
tnwNames.unshift(tnwNewvalue);
document.getElementById("demo1").innerHTML = "The new array is : " + tnwNames.join(", ");
}

To see demo


ZilaStar ICT Aug 19 2021, 19:47:15

splice (JavaScript Array Method)

const tnwNames = ["Hla", "Mya", "Soe", "Moe", "Noe"];

function tnwFun1(){
document.getElementById("demo").innerHTML = tnwNames.join(", ");
}

function tnwFun2(){
document.getElementById("demo").innerHTML = "The original array is :
" + tnwNames.join(", ");
let result = tnwNames.splice(2, 2, "Aung", "Kyaw", "Tun");
document.getElementById("demo1").innerHTML = "The removed elements are :
" + result.join(", ");
document.getElementById("demo2").innerHTML = "The new array is :
" + tnwNames.join(", ");
}


ZilaStar ICT Jul 24 2021, 19:46:34

sort (JavaScript Array Method)

//1. sort alphabetically
/**
const countries = ["Myanmar", "Singapore", "Malaysia", "USA", "Thailand", "Vietname"];

function tnwFun1(){
document.getElementById("demo").innerHTML = countries.join("
");
}

function jsSort(){
let result = countries.sort();
document.getElementById("demo").innerHTML = result.join("
");
}

function jsReverse(){
let result = countries.reverse();
document.getElementById("demo").innerHTML = result.join("
");
}

//2. Sort randomly

const tnwNums = [20, 17, 30, 38, 40, 50, 28, 12];

function tnwFun1(){
document.getElementById("demo").innerHTML = tnwNums.join("
");
}

function tnwFun2(){
let result = tnwNums.sort(tnwFun3);
document.getElementById("demo").innerHTML = result.join("
");
}

function tnwFun3(a, b){
return 0.5 - Math.random();
} */

// 3. Sort Numerically

const tnwNums = [20, 17, 30, 38, 40, 50, 28, 12, 4];

function tnwFun1(){
document.getElementById("demo").innerHTML = tnwNums.join("
");
}

function jsSort(){
let result = tnwNums.sort(function(a, b){return a - b;});
document.getElementById("demo").innerHTML = result.join("
");
}

function jsReverse(){
let result = tnwNums.sort(function(a, b){return b - a;});
document.getElementById("demo").innerHTML = result.join("
");
}


ZilaStar ICT Jul 03 2021, 19:46:00

some (JavaScript Array Method)

const tnwNums = [20, 39, 48, 58, 68, 70, 85, 90];

function tnwFun1(){
document.getElementById("demo").innerHTML = tnwNums.join(", ");
}

function tnwFun2(){
let result = tnwNums.some(tnwFun3);
document.getElementById("demo").innerHTML = tnwNums.join(", ");
document.getElementById("demo1").innerHTML = result;
}

function tnwFun3(num){
let chkInput = document.getElementById("chknum").value;
return num > chkInput;
}


ZilaStar ICT Jun 13 2021, 19:45:18

slice (JavaScript Array Method)

const tnwNums = [20, 29, 30, 39, 40, 47, 50, 70];

function tnwFun1(){
document.getElementById("demo").innerHTML = tnwNums.join(", ");
}

function tnwFun2(){
let result = tnwNums.slice(1, 4);
document.getElementById("demo").innerHTML = "The original is: " + tnwNums.join(", ");
document.getElementById("demo1").innerHTML = "The new array is: " + result.join(", ");
}


ZilaStar ICT May 29 2021, 19:44:28

shift (JavaScript Array Method)

const tnwNums = [20, 30, 40, 50, 60, 70, 90];

function tnwFun1(){
document.getElementById("demo").innerHTML = tnwNums.join(", ");
}

function tnwFun2(){
let result = tnwNums.shift();
document.getElementById("demo").innerHTML = tnwNums.join(", ");
document.getElementById("demo1").innerHTML = "The removed element is: " + result;
}


ZilaStar ICT May 07 2021, 15:50:24

reverse (JavaScript Array Method)

const tnwNums = [20, 30, 40, 50, 60, 70];

function tnwFun1(){
document.getElementById("demo").innerHTML = tnwNums.join("
");
}

function tnwFun2(){
let result = tnwNums.reverse();
document.getElementById("demo").innerHTML = result.join("
");
}


ZilaStar ICT Apr 12 2021, 15:49:51

reduceRight (JavaScript Array Method)

const tnwNum = [20, 9, 20, 8, 100];

function tnwFun1(){
document.getElementById("demo").innerHTML = tnwNum.join(", ");
}

function tnwFun2(){
var result = tnwNum.reduceRight(tnwFun3);
document.getElementById("demo").innerHTML = result;
}

function tnwFun3(numRight, sum){
return numRight - sum;
}


Page : 8 of 30
To Contact
Available Services
Terms and Conditions