1/13 Introduction to Functions in Java Script; wrong string?


#1

So I've been typing up the statement

var speed = 65;

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");
}

but the system keeps saying that it's printing out the wrong string. If dire and specific information could be given on the current topic it would be greatly appreciated.


#2

here is you define speed

var speed =65;

here you define function as variable:

var drive = function(speed){
//the condition is
if (speed > 80){
console.log("slow down");
}
else {
console.log("drive safe");
}
}

now invoke the function,

drive(); //will console" drive safe"  because var speed is still 65

remember you can modified variable, and variable spee which we put inside function argument

 drive(90); // will console "slow down" because it has been modified to 90 look at the if condition.

#3

I still don't understand. I've tried to use your method but it said that I still got it wrong. Could you perhaps specifically tell what is wrong and how to fix it? Thank you for trying to help out with my mistakes.


#5

var speed = 65;
if (speed>80) {
console.log("Slow down")
}

else {
console.log("Drive safe")
}

Hope this helps!