Basics of Programming II

Learn the essential programming concepts of functions and control flow.

Start[missing "en.views.course_landing_page.learn-how-to-code.course_illustration" translation]
  1. 1

    This lesson requires you to know the basics of hamburger-making: Place the bread down Add the burger patty Add the pickles Place the bread on top What if you had to say each step every tim…

  2. 2

    Instead of giving those instructions for every hamburger, we can group and name them as a single function: […] A function is a sequence of instructions that performs a specific task, package…

  3. 3

    Not everyone wants to eat hamburgers. We could write a new function for each new sandwich type, but that takes a lot of work and risks making mistakes. Instead we’ll generalize the hamburger fu…

  4. 4

    A sandwich wouldn’t be complete without fries and dessert! Here are the instructions to make the complete meal: * Add bread, Add burger patty, Add fried potatoes, Add pickles, Add bread, Add salt…

  5. 5

    Time to get coding! It’s okay if you don’t recognize all the symbols in this code: we’ll walk you through the parts you need to know. The […] function is provided in main.js. It is defined…

  6. 6

    Well done! Functions are a fundamental concept in programming, and learning the basics will serve you wherever your path leads, regardless of language or domain. To review: * A function is a sequ…

  1. 1

    How do computers make decisions? Here are a few examples: Web surfing: Open the browser, load the text, load the images. Social media: If the user’s profile is private, hide their posts. Other…

  2. 2

    If the user’s profile is private, hide their posts. Otherwise, make them visible. Computers can run instructions on their own, leaving us to work on more interesting and creative problems. But c…

  3. 3

    Repeat a sound four times a measure. Computers are good at repetitive tasks: they exactly follow instructions and perform them quickly. But if the programmer has to write the same instructions f…

  4. 4

    Collect shipping and email address. Reject a purchase if either is incorrect. Errors, or exceptions, happen all the time in programming. You can’t escape them. But you can handle them gracefully…

  5. 5

    Let’s recreate the conditional control structure using JavaScript! (The one about social media posts, remember?) ![Diagram of conditional control structure](https://s3.amazonaws.com/codecademy-c

  6. 6

    Well done! Control flow is a fundamental concept in programming, and learning the basics will serve you wherever your path leads, regardless of language or domain. In review: - Control flow is t…

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo

Basics of Programming II

Start[missing "en.views.course_landing_page.learn-how-to-code.course_illustration" translation]