This is my first ever using mod operator. What I've done so far is declare and initialize a variable and parsed the string to an integer. I used a if statements to determine whether the remainder is an even or odd number. Then I used document.write to display the output for each if statement.
But the output is not showing in the browser. The error console message is that I have an invalid assignment on the left-hand side. I tried switching the left-hand side to the right-hand side but the error is still invalid on the left-hand side.
The other thing is I'm not sure whether I should be using the parse since I read that the mod operator attempts to convert the string to a number. But I'm a little confused on this.
Anyway, here is the code: Any suggestions?
<?xml version ="1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1 /DTD/xhtml1-strict.dtd">
<html xmlns - "http://www.w3.org/1999/xhtml>
<html>
<head>
<script type="text/javascript">
//Declare variables
var num = 18;
//converts to integer
num = parseInt(num);
//write to output
if(num % 6 = 0){
document.write(% + "<h2> is an even number</h2>");
}
if(num % 6 != 0){
document.write(% + "<h2> is a odd number</h2>");
}
//end if
</script>
</head>
<body>