Millions of ds


#1



var isEven = function(number) {
  // Your code goes here!
  if(number % 2 === 0){
      console.log("d")
      return true
      }
 else if(isNaN(number)){
    return false
console.log("nothing")
return false
}

};
isEven(2). 
why is this printing so many ds?!
and why isn't the else/if statement working
it says SyntaxError: Unexpected token else


#2

Is there a period at the end of the last line? That should be a ; if that wasn't a typo transferring the code.


#3

Also, you're missing an else statement after the first return false. Mine looked like this.

 else if (isNaN(number)){ 
      return "This is not a number!";
  }
  else{
      return false;
  }
};

#4

This is the result of SCT (submission correctness test). Codecademy is executing your function to check if it works correctly.

You can add a line at the end of your file to mark end of output:

var isEven = function(number) {
    // Your code goes here!
    if (number % 2 === 0) {
        console.log("d");
        return true;
    } else if (isNaN(number)) {
        console.log("nothing");
        return false;
    }
};
isEven(2);
console.log("Everything below this line is not a result of your script");

@ghughes13 dot at the end would result in the "unexpected end of input" error.


#5

i think it was a transfere typo thanx all


#6

but even if I figure this out, what in the code makes it print so many ds?


#7

Do you know how to make like a moving scene, like mincraft with javascript. (I am aware that if i'm having trouble with this, I won't even be able to code a dirt block)


#8

any line of correct code?


#9

I already explained this. This is not a result of your code. Read my comment again.


#10

why would it returning it back result in so many ds? and what do you mean you can add aline to end the of input?


#11

I worked on it,
var isEven = function(number){
// Your code goes here!
if(number % 2 === 0){
return false
}
else if(isNaN("number"){
return true
}

else{
return false
};
}
isEven(2)
console.log("asdjfkasdok");
now its says SyntaxError: Unexpected token {


#12

why would it returning it back result in so many ds?

This is the result of SCT (submission correctness test). Codecademy is executing your function to check if it works correctly.

This is not output of your script. Execute your script in neutral environment (outside of the codecademy) and you will see ->

Code
var isEven = function(number) {
    // Your code goes here!
    if (number % 2 === 0) {
        console.log("d");
        return true;
    } else if (isNaN(number)) {
        console.log("nothing");
        return false;
    }
};

isEven(2);

and what do you mean you can add aline to end the of input?

You can separate output of your script and the result of SCT by adding a single console.log statement to the end of your file:

var isEven = function(number) {
    // Your code goes here!
    if (number % 2 === 0) {
        console.log("d");
        return true;
    } else if (isNaN(number)) {
        console.log("nothing");
        return false;
    }
};
isEven(2);
console.log("Everything below this line is not a result of your script");

And now the output is:

d
Everything below this line is not a result of your script
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d

#13

oh, thank you for explaining!!! :slight_smile:


#14

Hi, @factoradic ! I had the same problem as @star_wars_is_awesome and got it right by ignoring the result as you instructed but... for someone that's learning this is really confusing.

You always expect the code output to be only what you asked for. Can't Codeacademy make the SCT (submission correctness test) invisible to the user? I spent hours trying to figure out what I did wrong and got similar problem with another exercise: right code, unexpected result.

I am now testing everything with weird results under another website because I'm always uncertain if I got the lesson wrong or if it's a result of the SCT.


#15

Hello :slight_smile:

for someone that's learning this is really confusing

I totally get it and I think the same. I only tried to help as best as I could. If there is something wrong with the way I handled this discussion than just let me know :wink: I can change my behaviour, but that's all, I don't have any special powers here.

Can't Codeacademy make the SCT (submission correctness test) invisible to the user?

Of course, they can make that. Gosh, even I would be able to make that (if I could change the SCT). The problem is that codecademy just doesn't care.

Problems related to the visible output of the SCT were reported many years ago and they are still here. Now, codecademy staff argues that these courses are old and that is why they don't want to fix them in any way. The truth is that they never cared about the quality of content. The number of users is still raising so I bet that they will never change their approach to education.


And now you should take a moment and decide if the codecademy is the right place for you. Is codecademy a good learning resource? Nope. But you can gather points! :slight_smile:

If you think seriously about programming - find a good book about the specific language / topic you are interested in (you can ask any experienced programmer to help you with picking a book or the topic) and leave this place behind you.


Why is this code logging to console 3 times?
#16

Hi, @factoradic!

No problem the way you handled the discussion I just asked you because you were pointed as a moderator on your profile (so I thought you were from codeacademy team) and I was suggesting an improvement. :slight_smile:

I don't think codeacademy a bad place to learn stuff from zero but I don't think it's a place you will always improve either.

It's good to learn new stuff but practice on a real work environment will always be best to understand tricks and debug.

So, I'm sorry if it sounded like I was criticizing you. I just wanted to suggest an improvement to codeacademy team and thought you were part of that team ^^

English is not my native language so I apologize if what I wanted to express didn't worked out and sounded bitter.

Best Regards


#17

And speaking of SCT: this bookmarklet should allow you to view the test code of an exercise.