Today is uki 20th class
Today I study javascript.
1)
<script>
for(i=0; i<10; i++)
document.write("Hello world"+"<br>");
</script>
<p id="demo"></p>
<script>
var text="";
var i;
va
for(i=10; i>0; i--)
{
text+="The number is "+i+"<br>";
}
document.getElementById("demo").innerHTML=text;
</script>
2)
<p id="demo"></p>
<script>
var fruit = ["Apple", "Orange", "Mango", "Pineapple"];
var i;
var text="";
for(i=0; i<fruit.length; i++)
{
text+=fruit[i] +"<br>";
}
document.getElementById("demo").innerHTML=text;
</script>
<p id="demo"></p>
<script>
var txt="";
var person={fname:"John", lname:"Doe", age:"25"};
var x;
for (x in person) {
txt += person[x]+" ";
}
document.getElementById("demo").innerHTML=txt;
</script>
3)
<p id="demo"></p>
<script>
var grade= ["A", "B", "C", "D","F"];
for(i=0;i<grade.length; i++)
{
switch(grade[i])
{
case "A":
document.write("your garde is "+grade[i]+ " Very good<br />");
break;
case "B":
document.write("your garde is "+grade[i]+ " Good<br />");
break;
case "C":
document.write("your garde is "+grade[i]+ " Avg<br />");
break;
case "S":
document.write("your garde is "+grade[i]+ " Pass<br />");
break;
case "F":
document.write("your garde is "+grade[i]+ " fail<br />");
}
}
</script>
this coding output is tomorrow this blog.
thankyou
No comments:
Post a Comment