Javascript to check speed

var speed = 85;

// Complete the condition in the ()s on line 4
if (speed > 80 ) {
	// Use console.log() to print "Slow down"
	console.log("Slow down")
else {
	// Use console.log() to print "Drive safe"
    console.log("Drive safe")


Error: It looks like you didn’t print the correct string. Check your condition in the if statement, and your console.log statements

So what’s the question?

Check the requirements of the exercise again. Does it tell you to use a speed of 85 or 65?

Yes, when I input 65, it gives me no errors. But if I put 85, it gives me the above error

Those websites for learning Javascript via code always are nitpicky when it comes to the excercises. You can have perfectly valid code fail the exercise due to the website being stupid. Don’t worry about it.

Maybe parseInt() would resolve the problem?

I would hope NOT unless the speed is expected to be entered in binary or hexadecimal or some other number base.

I know, same here :wink: I was wondering if code academy was messing with the datatype somehow, though I can’t think of what it might be doing to be causing it.

Thanks all for the responses! :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.