Please enable JavaScript to use CodeHS

AP Computer Science Principles in JavaScript

Description

In this lesson, students will discuss how computing is used. They will also set goals for this course and beyond.

Objective

Students will be able to:

  • Identify and brainstorm ways computers have impacted their own lives, as well as society, economy, and culture
  • Develop their own learning objectives for the course by reflecting on why they are taking this course
Description

In this lesson, students are introduced to Karel the Dog and how Karel can be given a set of instructions to perform a simple task.

Objective

Students will be able to:

  • Recognize, explain, and use the commands that Karel can be given. These commands are: move(), putBall(), takeBall() and turnLeft().
Description

In this lesson, students build on their understanding of how Karel the Dog can be given a set of instructions to perform a simple task.

Objective

Students will be able to:

  • Recognize, explain, and use the commands that Karel can be given
  • Debug and rework their code as well as someone else’s code
Description

In this lesson, students will learn how to define and call a function using proper syntax.

Objective

Students will be able to:

  • Define and call functions
Description

In this lesson, functions will be used to teach Karel a new word or command. Using functions allows programs to be broken down into smaller pieces and makes it easier to understand.

Objective

Students will be able to:

  • Understand what functions are, how they are used and how using them improves programs
  • Design and implement their own functions to solve problems
Description

In this lesson, students will learn the importance of writing readable code and how using the start function can help achieve this.

Objective

Students will be able to:

  • Explain the importance of writing readable code
  • Analyze and compare the readability of different programs
  • Use the start function to make their programs more readable
Description

In this lesson, students learn top down design and decomposition as the processes of breaking big problems into smaller, manageable pieces. The functions improve the readability of the code and avoid repeated code.

Objective

Students will be able to:

  • Break a large problem down into smaller, simpler problems
  • Write functions that solve the simpler problems, and use them as building blocks to solve the larger problem
  • Compare programs and identify good vs. poor decomposition
Description

In this lesson, students will learn how to utilize comments in their code to explain what their code is doing. Comments should include preconditions and postconditions. Preconditions are assumptions we make about what is true before a function is called in our program. Postconditions are what should be true after a function is called in our program.

Objective

Students will be able to:

  • Explain the preconditions and postconditions of a function
  • Create clear and readable comments in their code that help the reader understand the code
  • Explain the purpose of comments
Description

In this lesson, students will learn about abstraction. Abstraction is the act of managing complexity by dissociating information and details in order to focus on relevant concepts.

Objective

Students will be able to:

  • Understand abstraction as the different levels of detail and complexity
  • Understand the importance of abstracting away complexity to solve problems more efficiently
Description

In this lesson, students will be introduced to SuperKarel and APIs. SuperKarel includes commands like turnRight() and turnAround() since they are so commonly used. These commands come prepackaged with the SuperKarel library (API).

Objective

Students will be able to:

  • Write programs that use SuperKarel instead of Karel
  • Utilize the new toolbox of commands that SuperKarel provides over Karel
  • Read the documentation to understand how to use an API (SuperKarel is an example of this)
Description

In this lesson, students learn how to use for loops in their programs. The for loop allows you to repeat a specific part of code a fixed number of times.

A for loops is written as follows:

for(var i = 0; i < 4; i++)
{
    // Code to be repeated 4 times
}
Objective

Students will be able to:

  • Create for loops to repeat code a fixed number of times
  • Explain when a for loop would be a useful tool
  • Utilize for loops to write programs that would be difficult/impossible without loops
Description

In this lesson, students will learn about conditions and if statements. A condition is a function that returns a true/false answer. JavaScript uses if statements as a way to make decisions and execute specific code. If statements are helpful in writing code that can be used in different situations.

Objective

Students will be able to:

  • Use conditions to gather information about Karel’s world (is the front clear, is Karel facing north, etc)
  • Create if statements to only execute code if a certain condition is true
Description

In this lesson, students will take a deeper look into conditional statements, more specifically if/else statements. If/else statements allow for one thing to be done if a condition is true, and something else otherwise.

We write if/else statements like this:

if(frontIsClear()) {
    // code to execute if front is clear
} else {
    // code to execute otherwise
}
Objective

Students will be able to:

  • Explain the purpose of an If/Else statement
  • Create If/Else statements to solve new types of problems
  • Identify when an If/Else statement is appropriate to be used
Description

In this lesson, students are introduced to a new type of loop: while loops. While loops allow Karel to repeat code while a certain condition is true. While loops allow for the creation of general solutions to problems that will work on multiple Karel worlds, rather than just one.

Objective

Students will be able to:

  • Explain the purpose of a while loop
  • Create while loops to repeat code while a condition is true
  • Utilize while loops to solve new types of problems
  • Test their solutions on different Karel worlds
Description

In this lesson, students take a look at all of the control structures. Control structures can be selective, like if and if / else statements and are based on a condition. Other control structures are iterative and allow for repeated code like for loops and while loops. Basically, control structures control the way the commands execute.

Objective

Students will be able to:

  • Identify the different control structures that can be used to modify the flow of control through a program
  • Combine control structures to solve complicated problems
  • Choose the proper control structure for a given problem
Description

Debugging is a very important part of programming. In this lesson, students learn how to effectively debug their programs.

Objective

Students will be able to use debugging strategies to find and fix errors in their code.

Description

In this lesson, students are introduced to algorithms which are step by step instructions that solve a problem. Programs implement algorithms. All algorithms are built using sequencing, selection, and iteration. Karel has control structures for each of these. This lesson is designed to test students? knowledge of control structures and algorithm design in preparation for upcoming Karel challenges.

Objective

Students will be able to:

  • Analyze an algorithm and explain why it works
  • Use control structures to create general algorithms that work on all Karel worlds
Description

In this lesson, students will learn the proper way to indent their code. Indentation is especially important when using multiple loops, functions, and if statements to show the structure of the code. Indentation provides a good visual approach to see which commands are inside vs. outside of a loop or if statement.

Objective

Students will be able to:

  • Explain why it is important to indent code
  • Identify proper indentation
  • Modify a program to have proper indentation
  • Write programs with proper indentation
Description

In this lesson, students are introduced to Ultra Karel! Ultra Karel has all the abilities of Super Karel, plus two new functions (paint and isColor) added to the API.

Students will explore the Ultra Karel API and use Ultra Karel’s ability to paint the grid world to create digital images. Students will create generalized algorithms that solve Ultra Karel problems for multiple worlds.

This lesson is the first time students will use functions that accept parameters as inputs.

Objective

Students will be able to:

  • Use Ultra Karel commands to paint Karel’s world
  • Call functions that accept parameters as inputs
  • Explain the relationship between a function and a parameter
  • Create generalized Ultra Karel algorithms that correctly solve multiple Karel worlds
  • Identify differences between the Super Karel API and the Ultra Karel API
Description

In this lesson, students will synthesize all of the skills and concepts learned in the Karel unit to solve increasingly challenging Karel puzzles.

Objective

Students will be able to:

  • Define a problem in their own words and plan out a solution to the problem
  • Break a large problem down into smaller pieces and solve each of the pieces, then use these solutions as building blocks to solve the larger problem
  • Utilize the proper control structures to create general solutions that solve multiple Karel worlds
  • Write clear and readable code using control structures, functions, decomposition, and comments
Description

In this lesson, students complete a summative assessment of the unit’s learning objectives.

Objective

Students will be able to:

  • Prove their knowledge of control structures, functions, decomposition, and comments through a multiple choice quiz