JavaScript
JavaScript:
Change HTML,Hide,Show,Date:
<!DOCTYPE html>
<html>
<head>
<title>What JS can do?</title>
</head>
<body>
<h1>What js can do?</h1>
<p id="demo">This text will be changed.</p>
<button onclick="document.getElementById('demo').innerHTML = 'shuvo i hate you.'">Click Me!</button>
<hr />
<h1>Light on off</h1>
<button onclick="document.getElementById('demo1').src ='https://i.imgur.com/ASCo6S0.gif'">Turn On</button>
<img src="https://i.imgur.com/ASCo6S0.gif" id="demo1">
<button onclick="document.getElementById('demo1').src = 'https://i.imgur.com/S1JE0Op.gif'">Turn Off</button>
<hr />
<h1>Hide and Show</h1>
<button onclick="document.getElementById('demo2').style.display = 'none'">Click to vanish me!</button>
<button onclick="document.getElementById('demo2').style.display = 'block'">Click to vanish me!</button>
<p id="demo2">Bangladesh is my motherland</p>
<h1>Date</h1>
<p id="demo3"></p> <h1>Date</h1>
<button onclick="document.getElementById('demo3').innerHTML = new Date()">Click to See Date</button>
</body>
</html>
//Generate Random Number from min to max;
function getRandomNumber(min,max) {
return Math.floor(Math.random()*(max-min)+min);
}
var x = getRandomNumber(4,9);
console.log(x);
</script>
//Generate Random Number from min to max;
function getRandomNumberBoth(min,max) {
return Math.floor(Math.random()*(max-min+1)+min);
}
var x = getRandomNumber(4,9);
console.log(x);
</script>
var ar = [1,4,5,6,8,9,8,7,6,5,3,12];
ar.sort(function(a,b){return a-b})
console.log(ar);
</script>
Get Random Number:
<script>//Generate Random Number from min to max;
function getRandomNumber(min,max) {
return Math.floor(Math.random()*(max-min)+min);
}
var x = getRandomNumber(4,9);
console.log(x);
</script>
Get Random Number Both:
<script>//Generate Random Number from min to max;
function getRandomNumberBoth(min,max) {
return Math.floor(Math.random()*(max-min+1)+min);
}
var x = getRandomNumber(4,9);
console.log(x);
</script>
Sort numerical Values:
<script>var ar = [1,4,5,6,8,9,8,7,6,5,3,12];
ar.sort(function(a,b){return a-b})
console.log(ar);
</script>
Reverse numerical Values
<script>
var ar = [1,4,5,6,8,9,8,7,6,5,3,12];
ar.sort(function(a,b){return b-a})
console.log(ar);
</script>
No comments