Intro to functions - What I am doing wrong?


#1


https://www.codecademy.com/pt/courses/javascript-beginner-en-6LzGd/0/1?curriculum_id=506324b3a7dffd00020bf661#


Ops, tente outra vez. It looks like you didn't print the correct string. Check your condition in the if statement, and your console.log statements.


var speed = 65;
var drive = function(speed) {

if(speed >= 80) {
	console.log("Slow down")
	
}
else {

    console.log("Drive safe")

}
}


#2

HI you added a function around your if and else statement so you should call the function with 65 and remove.

var speed = 65;

#3

Not really following... I tried this:

var drive = function(speed) {

if(speed >= 80) {
console.log("Slow down")

}
else {

console.log("Drive safe")

}
}


#4

yes, now you should call the function drive with 65


#5

It worked when written like so:

var speed = 65;

if(speed >= 80) {
console.log("Slow down")

}
else {

console.log("Drive safe")

}


#6

because that what they aske you to do...

But

you could also do it like you did ...

var drive = function(speed) {
     if(speed >= 80) {
         console.log("Slow down")
    }
    else {
       console.log("Drive safe")
    }
}

//call the function drive
drive(65);

#7

Yes, but I tried it first like this, without adding the function and it did not work.. maybe I had some syntax errors.. well now I can move on.

thanks


#8

Oh, yes... ill try that now.