View on GitHub

learning-journal

this site is for 102d9 class

linking javaScript with htmal

to link javaScript with html we use script tag

the best place to add the script tag is before the closing bodytag


<script src="js/ add-content.js"></ script> 

Note that JavaScript is case sensitive so hourNow means something different to HourNow or HOURNOW.

Data Type :

Note that Numbers are not only used for things like calculators; they are also used for tasks such as:

example of script :


var today = new Date(); 
var hourNow = today.getHours(); 
var greeting; 
if (hourNow > 18) { 
    greeting = 'Good evening!'; 
    else if (hourNow > 12) { 
    greeting = ' Good afternoon!'; 
    else if (hourNow > 0) { 
    greeting = 'Good morni ng!'; 
    else { greeting = 'Welcome! ' ; 

document .write( ' <h3>' +greeting + ' </ h3>');