Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Exercise 4.5 Write a javascript that ask the user to enter a number between 20 a

ID: 3811929 • Letter: E

Question

Exercise 4.5 Write a javascript that ask the user to enter a number between 20 and 40. Your program will then output a paragraph with font-size as specified by the user. If the user entered number is greater than 40 then you program will make the font-szie 40. If the number is less than 20 or negative then you rpogram will make the display font size 20. If the number is even then the text color would be lightgreen and it out say it is cool. If the number is an odd number then the text color will be red and it says hot. Assuming the paragraph will say “I like internet computing. It is cool!!!” if number is even. If the number entered after modified become odd then the output is “I like internet computing. It is hot!!!”

Explanation / Answer

Answer:

<html>

<body>

<p id="demo"></p>

<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>

<script>

function myFunction() {

    var Font = prompt("Please enter font size", 20);

   if (Font >40) {Font=40};

   if (Font <20) {Font=20};

if (Font != null) {

   if (Font %2==0){

document.getElementById("demo").innerHTML =

"I like Internet computing. It is cool!!!";     

       $("#demo").css("font-size", Font+"px");

       $("#demo").css("color", "lightgreen");

       }

       else

       {  

       document.getElementById("demo").innerHTML =

"I like Internet computing. It is Hot!!!";

       $("#demo").css("font-size", Font+"px");

       $("#demo").css("color", "red");

       }

}

}

myFunction();

</script>

</body>

</html>