![]() |
Simple statement to find it number is odd or even
Here it is:
Code:
var isEven = function(number) {This seems to return false, but I have no idea why. AFAIK if you put in an even number, it should hit the if statement, come up with no remainder and so return true! Sadly it returns false every time. I know this is very simple stuff guys but please don't make fun of me:( I learn better when I can ask stupid questions and you only have to ask them once! |
if(isEven%2===0){
should be if(number%2===0){ You are testing whether the number is odd/even, not the function! It is dangerous to use number as the name of a variable - too easily confused with the Javascript method Number(). Quizmaster: In 1917 King George V changed the name of the British royal house from Saxe-Coburg Gotha to what? Contestant: Tudor. |
DAMMIT! Knew it would be something simple! Thanks very much!
|
Quote:
<grin style="MONSTROUS!"> Who but a Brit would care? </grin> :o:o:o |
Quote:
|
Oh, come on, Philip! I knew all that! Just having fun.
I even knew that the name was originally "Tewdwr" and/or "Tudur". (Have to admit I don't know where George V came up with the name "Windsor" other than, presumably, from Windsor Castle. Did it ever have any actual royal associations before that?) |
Quote:
|
simplified :
Code:
function isEven (n) { |
| All times are GMT +1. The time now is 10:48 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.