0% found this document useful (0 votes)
24 views2 pages

Script de JavaScrip

Classnotes from PNT

Uploaded by

anon_88078045
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Script de JavaScrip

Classnotes from PNT

Uploaded by

anon_88078045
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

<!

DOCTYPE html>
<html>
<body>
<div id="container1">
<p id="output">Output</p>
<script>
document.getElementById("output").innerHTML = "Internal JS";

var currentDate = new Date();


window.alert(currentDate);
</script>
</div>

<h1>Arrays in JS</h1>

<div id="container2">
<h4> Array 1</h4>
<p id="demo1"></p>
<script>
var a = ["ab", "cd", "ef"];
document.getElementById("demo1").innerHTML = a;
</script>
</div>

<div id="container3">
<h4> Array 2</h4>
<p id="demo"></p>
<script>
var cars = ["BMW", "volvo", "Saab", "Ford", "Audi"];
var text = "";
var i;
for(i = 0; i < cars.length; i++){
text+= cars[i] + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
</div>

<div id="container4">
<h4>Functions and conditionals</h4>
<p>Click the button to get a time-based greeting:</p>

<button onclick="myFunction()">Try it!</button>


<p id="demo3"></p>

<script>
function myFunction(){
var greeting;
var time = new Date().getHours();
if (time < 10) {
greeting = "Good morning!";
} else if (time < 20){
greeting = "Good day!";
} else {
greeting = "Good evening!";
}
document.getElementById("demo3").innerHTML = greeting;
}
</script>
</div>

<div id="container4">

</div>

<!-- <script type="text/javascript" src="script.js"></script>-->


</body>
</html>

You might also like