Introduction to Functions in JS

Programming is simply a way to give instructions to the computer.

In Getting Started, we learned about if / else statements.

We want to keep learning ways to instruct the computer to perform repeatable tasks efficiently.


Let's briefly review! Use an if / else to check how fast you're driving.

  1. If speed is greater than 80, use console.log to print "Slow down"
  2. Otherwise (else), use console.log to print "Drive safe"
Stuck? Get a hint! Hint
Get live, fast support from Codecademy Advisors when you get stuck. Learn more.

In this case "Drive safe" should be logged, since 65 is less than 80.

Remember, if/else works like this:

if (condition) {
    // Do something
} else { // Otherwise...
    // Do something else!