Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Netscape try/catch problems

Status
Not open for further replies.

joeoz

Programmer
Oct 18, 2001
24
US
Today I was trying to write a simple program to solve the Math "Problem of the Month" at my school. The problem was fairly simple and I had already solved it by hand. I decided to try a brute force approach looping using various bounds for a and b. When I run this in IE it's fine but NS 4.7 gives me an error that says "try is a reserved identifier." Are try/catch blocks not allowed or implemented differently in Netscape?

The page is found at
This isn't anything urgent. Just a curiosity about browser differences in implementation of JavaScript.

Thanks for any help.

<script language=&quot;javascript&quot;>
var sum=0;
var outstr=&quot;The integers (a,b) which satisfy the problem are:<br>&quot;;
for(var a = -100;a<=100;a++)
{
for(var b = -100;b<=100;b++)
{
try
{
sum = Math.sqrt(a + Math.sqrt(-b)) + Math.sqrt(a - Math.sqrt(-b));
if(sum==4)
outstr += &quot;<font size=\&quot;3\&quot;><b>(&quot;+a+&quot;,&quot;+b+&quot;)</b></font><br>&quot;;
}
catch(err)
{}
}
}
document.write(outstr);
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top