The most viewed items
const tnwAges = [19, 39, 28, 43, 29, 45, 53];
function tnwFun1(){
document.getElementById("demo").innerHTML = tnwAges.join("
");
}
function tnwFun2(){
document.getElementById("demo").innerHTML = tnwAges.findIndex(chkAge);
}
function chkAge(age){
return age > document.getElementById("myAge").value;
}
const tnwAges = [19, 39, 28, 43, 29, 45, 53];
function tnwFun1(){
document.getElementById("demo").innerHTML = tnwAges.join("
");
}
function tnwFun2(){
document.getElementById("demo").innerHTML = tnwAges.find(chkAge);
}
function chkAge(age){
return age > document.getElementById("myAge").value;
}
const tnwAges = [25, 18, 29, 20, 40, 32, 53, 24];
function tnwFun1(){
document.getElementById("demo").innerHTML = tnwAges.join("
");
}
function tnwFun2(){
const result = tnwAges.filter(chkAge);
document.getElementById("demo").innerHTML = result.join("
");
}
function chkAge(age){
return age > 20;
}
const tnwNames = ["Aye Aye", "Nwe Nwe", "Hla Hla", "Mya Mya", "Soe Soe", "Moe Moe"];
function tnwFun1(){
document.getElementById("demo").innerHTML = tnwNames.join("
");
}
function tnwFun2(){
const result = tnwNames.fill("Aung Aung", 1, 3);
document.getElementById("demo").innerHTML = result.join("
");
}
const tnwAge = [20, 29, 48, 76, 50, 38, 39];
function tnwFun1(){
document.getElementById("demo").innerHTML = tnwAge.every(tnwFun2);
}
function tnwFun2(chkAge){
return chkAge > 19;
}
const tnwNames = ["Hla Hla", "Mya Mya", "Aye Aye", "Nwe Nwe", "Soe Soe", "Moe Moe", "Aung Aung"];
const y = tnwNames.entries();
for(x of y){
document.write(x + "
");
}
const people = ["Hla", "Mya", "Aung", "Maung", "Soe", "Noe", "Moe"];
function tnwFun1(){
document.getElementById("demo").innerHTML = people.join("
");
}
function tnwFun2(){
const result = people.copyWithin(3, 0, 3);
document.getElementById("demo").innerHTML = result.join("
");
}
const girls = ["Aye Aye", "Nwe Nwe", "Htwe Htwe"];
const boys = ["Aung Aung", "Maung Maung", "Kyaw Kyaw"];
const students = ["Hla Hla", "Mya Mya", "Aung Ba", "Aung Mya"];
const people = girls.concat(boys, students);
document.write(people.join("
"));
length
Sets or returns the number of elements in an array.
prototype
Allows you to add new properties and methods to an Array object.
//length
/*
const countries = ["USA", "UK", "Canada", "Myanmar", "Singapore"];
function showLength(){
document.getElementById("demo").innerHTML = countries.length;
}
//prototype
Array.prototype.tnwCase = function(){
for(let i = 0; i < this.length; i++){
this[i] = this[i].toLowerCase(); //lower case
}
};
const countries = ["USA", "UK", "Canada", "Myanmar", "Singapore"];
countries.tnwCase();
function tnwFun(){
document.getElementById("demo").innerHTML = countries;
}*/
//Another example of prototype property
function Person(first, middle, last){
this.firstName = first;
this.middleName = middle;
this.lastName = last;
}
const myFriend = new Person("Aung", "Kyaw", "Soe");
Person.prototype.nationality = "Myanmar";
Person.prototype.age = 35;
function tnwFun(){
document.getElementById("demo").innerHTML = myFriend.age;
}
/*
const countries = ["USA", "UK", "Canada"];
document.write(countries);
//example one
const names = ["Hla Hla", "Mya Mya", "Soe Soe"];
document.write(names);
//example two
const cities = [
"Yangon",
"Mandalay",
"Meikhtila"
];
document.write(cities);
//example three
const countries = [];
countries[0] = "USA";
countries[1] = "UK";
countries[2] = "Canada";
document.write(countries);
//example four
//creating array by using new keyword
const countries = new Array("USA", "UK", "Canada");
document.write(countries); */
//Arrays are special types of objects
const myNmae = {first: "Thet", middle: "Naing", last: "Win"};
document.write(myNmae.last);
When we design the website, we need to use css and html together. html, css and javascript are the most important languages for those who are trying to get in front-end web development field. The following is the very basic sample of html and css.
Adding script between <head> and </head>
<html>
<head>
<title>TNW (Web Service & ICT Solutions)</title>
<script>
var txt = "<b>Welcome to TNW (Web Service & ICT Solutions)!</b><br /><br /> TNW provides the best ICT Solutions for your business by the reasonable price.";
function myFun(){
document.getElementById("demo").innerHTML = txt;
}
</script>
</head>
<body>
<p id = "demo">TNW</p>
<button type = "button" onclick = "myFun()">Click Here</button>
</body>
</html>
Open notepad or text editor and write the above codes. Then, save it as test.html and try to open by one of the browsers on your computer.
Adding Script between <body> and </body>
<html>
<head>
<title>TNW (Web Service & ICT Solutions)</title>
</head>
<body>
<p id = "demo">TNW</p>
<button type = "button" onclick = "myFun()">Click Here</button>
<script>
var txt = "<b>Welcome to TNW (Web Service & ICT Solutions)!</b><br /><br /> TNW provides the best ICT Solutions for your business by the reasonable price.";
function myFun(){
document.getElementById("demo").innerHTML = txt;
}
</script>
</body>
</html>
Open notepad or text editor and write the above codes. Then, save it as test.html and try to open by one of the browsers on your computer.
When we design the website, we need to use css and html together. html, css and javascript are the most important languages for those who are trying to get in front-end web development field. The following is the very basic sample of html and css.
<!DOCTYPE html>
<html>
<head>
<title>T N W</title>
<style type="text/css">
p{color:red; background:black; width: 200 px;}
</style>
</head>
<body>
<p>Hello, This is HTML Testing!</p>
</body>
</html>