Simple Operations

Hello,

I’m trying to perform simple javascript functions. I want to execute the following operations: addition, subtraction, multiply, division, and a even odd function.

So far I did the addition. Its not working and I was wondering if someone can offer help. Here’s what I have so far.

My HTML:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html>

<head>

<title> </title>

<script src=“ron3.js” type=“text/javascript”></script>
<link href=“ron3.css” type=“text.css” rel=“stylesheet”/>

</head>

<body>
<script src=“ron3.js” type=“text/javascript”>
document.writeln(add(10,2));
</script>

</body>

</html>

And then my external js file:

function add(num1+num2)

{
return num1 + num2;
}

In the book I’m reading, it shows me how to get the area of a rectangle by using: function CalcArea
var area (length* width);
return area;
I was thinking that instead of the function name add for addition I should use CalcSum. If anyone can direct me to a site that lists the function names for the operations I mention above, that would be great. My book seems to only cover area and leave the rest up to me.

Thanks

function add(num1, num2){
return num1+num2;
}

Thanks mrhoo. But does my html look right. I think that’s my problem a syntax error in the html.

thanks

<script src=“ron3.js” type=“text/javascript”>
document.writeln(add(10,2));
</script>

No script between the script tags is interpreted when a src is specified.
You need another set of script tags, or put all the code in the remote file,
or the whole script in the html.

<script src=“ron3.js” type=“text/javascript”>
</script>

<script type=“text/javascript”>
document.writeln(add(10,2));
</script>

Thanks Mrhoo. I got it to work. :cool::D:D