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

I\'m needing to create an HTML/Javascript page for something that I can\'t quite

ID: 3546040 • Letter: I

Question

I'm needing to create an HTML/Javascript page for something that I can't quite wrap my head around.  Here's what I have to do:


With Javascript, I have to create four buttons.  However, here's what they have to do.....


- the FIRST buton will print out (at the bottom of the page) all of the results (one after the other, in one column) for "4n+3".  

When I say "all of the results", I mean (for example) the first line will read" For n=1, 4n+3=..", and the result.  The next will be n=2, and so on, for results for n being 1 thru 9.  


The calculations HAVE to use for, while, or do-while loops.  No exceptions.  (ugh)


- the SECOND button will share the same format as the first, except its equation is 10-2n.


- the THIRD button will also share the same format, with its equation being n^2-2.  


- the FOURTH (and final) button will have a modified geometric sequence for ar^n, when a=3 and r=2.  



Like I said, I can't quite get the grasp of these equations while having to use the loops.  Can you help?

Explanation / Answer

TRY THIS ////

<html>

<head>

<script type="text/javascript">





function countClicks1()

{

document.getElementById("demo").innerHTML = "" ;

for(var n = 1 ; n < 10 ;n++)

{

count = 4*n + 3 ;

document.getElementById("demo").innerHTML += "n="+n+", 4*n + 3 =" +count+"<br>" ;



}

}


function countClicks2()

{

document.getElementById("demo").innerHTML = "" ;


for(var n = 1 ; n < 10 ;n++)

{

count = 10-2*n ;

document.getElementById("demo").innerHTML += "n="+n+", 10-2*n =" +count+"<br>" ;



}

}


function countClicks3()

{

document.getElementById("demo").innerHTML = "" ;


for(var n = 1 ; n < 10 ;n++)

{

count = n*n -2 ;

document.getElementById("demo").innerHTML += "n="+n+", n*n -2 =" +count+"<br>" ;


}

}


function countClicks4()

{

document.getElementById("demo").innerHTML = "" ;

var a=3 ; var r=2 ;

for(var n = 1 ; n < 10 ;n++)

{


count = a*(Math.pow(r,n)) ;


document.getElementById("demo").innerHTML += "a="+a+",r="+r+",n="+n+", a*r^n =" +count+"<br>" ;



}

}


</script>

</head>

<body>


<div align="center">

<button type="button" >4n+3 </button>


<button type="button" >10-2n</button>


<button type="button" >n^2-2</button>


<button type="button" >ar^n</button>

</div>

<h1>

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

</h1>

</body>

</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote