Here is an easy question I hope
Could you explain to me why there has to be this variable “theRoots” and it has to be equal to quotation marks so the result can be achived. Why should there be this line at all: result=result+"Square root of "+x+" is "+number+"\n"
I tried to write in the alert like this: alert ("Square root of "+x+" is "+number+"\n"); but it doesn’t work.
<html>
<head>
<title></title>
<script type="text/javascript">
function mySquareRoot()
{
the Roots="";
for (var x=0; x<20;x++)
{
number=Math.sqrt(x);
number=number*10;
number=Math.round(number);
number=number/10;
theRoots=theRoots+"Square root of "+x+" is "+number+"\n"
}
alert (theRoots);
}
</script>
</head>
<body>
<a href="javascript:mySquareRoot()">Click here</a>
</body>
</html>