javascript初級のいくつかの小さいコード

2715 ワード





function myFunc(){
	document.write("hello word")
	document.write("<h1>This is a header</h1>")
	document.write("<p>This is a paragraph</p>");
	document.write("<p>This is another paragraph</p>");
   
	var x = 2;
    var y = 3;
    var z = x+y;
    document.write(z)
	
    document.write("<p>")
    z==5? document.write("z==5"):document.write("z!=5")
    document.write("</p>")
    
    
    document.write("<p>")
    var d=new Date()
    var time=d.getHours()
    if (time<10) 
    {
    document.write("<b>Good morning</b>")
    }	else{
    	
    	document.write("<b>Good afternoon</b>")
    }	
    document.write("</p>")
    
    
    var d = new Date();
    theDay = d.getDay();
    switch(theDay){
    case 3:
    	document.write("W   ")
    	break;
    case 4:
    	document.write("thursday")
    	break;
    default:
    	doucument.write("you Gusses!")
    }
   
 /**   
  *    
    document.write("<p>")
    if(confirm("       ")){
    	alert("sure")
    }else{
    	alert("not")
    }
    document.write("</p>")
    
   alert( prompt("   ","   1"));
    */
    document.write("</p>")
    
    
    var x;
    var mycars = new Array();
    mycars[0]="Saab1"
    mycars[1]="Saab2"
    mycars[2]="Saab3"
    	
    for(x in mycars){
	  document.write(x)
	  document.write(mycars[x]+"<br/>") 
    } 	
    
    
    
    var a2 = new Array();
    for(i=0;i<4;i++){
    	a2[i]= new Array(4);
    	for(j=0;j<4;j++){
    		a2[i][j]="["+i+","+j+"]";
    		document.write(a2[i][j]+"</br>")
    	}
    }
    
    
    document.write("</p>")
    document.write(Math.round(4.7))
    document.write("</p>")
    document.write(Math.random())
    document.write("</p>")
    document.write(Math.floor(Math.random()*11)) 
    document.write("</p>")  
   
   
   
   
   
   }