Breaking

Post Top Ad

Your Ad Spot

Activity # 12

Additional JavaScript function activity

 

Additional JavaScript function activity


Create a function that takes the age and return the age in days.

 

 


 
 
 

<!DOCTYPE html>

<html>

<body>


<h2>JavaScript Functions</h2>


<p>This example calls a function to convert from Years to Days:</p>

<p id="demo" style="font-size:30px; color:red;"></p>


<button onclick="ask()">Click to Enter Age in Years</button>


<script>

function ask(){

var calcAge = prompt("Enter your Age in Years");

var days = get_age(calcAge);

document.getElementById('demo').innerHTML = days;


}


function get_age(calcAge){

var age1 = get_age1(parseInt(calcAge*365));

return age1;

}


function get_age1(calcAge){

var age2 = 'Days: '+ calcAge;

return age2;

}


</script>


</body>

</html>

 

 

 

No comments:

Post a Comment

  How to Submit the Practical Exam on Portal EdTechWorx  

Post Top Ad

Your Ad Spot

Pages