Please enable JavaScript to use CodeHS

Washington Foundations of Computer Science

Description

In this lesson, students learn about functions and parameters in the context of JavaScript, which builds on their prior knowledge of working with functions in Karel. This lesson focuses specifically on defining and calling functions, and passing simple, single parameters to functions.

Objective

Students will be able to…

  • Explain the purpose of functions
  • Create JavaScript functions
  • Utilize JavaScript functions to solve simple problems
  • Create functions that take in parameters as input
Description

In this lesson, students will work with, define and call their own functions that take in multiple parameters as input and print out output.

Objective

Students will be able to:

  • Explain the purpose of functions
  • Create JavaScript functions
  • Utilize JavaScript functions to solve simple problems
  • Create functions that take in multiple parameters as input, and use print statements for output
Description

In this lesson, students continue working with multiple parameters that create graphics as output which is very useful, since creating several different graphical objects involves writing the same code over and over again (set the size, set the color, set the location, etc).

Objective

Students will be able to:

  • Explain the purpose of functions
  • Create JavaScript functions
  • Utilize JavaScript functions to simplify graphics programs
  • Identify repeated code that can be simplified with functions and parameters
  • Create functions that take in multiple parameters as input, and create graphics as output
Description

In this lesson, students learn about return values so they can write functions that do some work and send the result back or use later in the program.

Objective

Students will be able to:

  • Explain the purpose of returning a value from a function.
  • Create functions that return values.
  • Create programs that call functions with return values and store the result for later use.
Description

In this lesson, students work with and define functions with return values and more than one parameter.

Objective

Students will be able to:

  • Explain the purpose of returning a value from a function.
  • Create functions that return values.
  • Create programs that call functions with return values and use the return values to solve a higher order problem.
Description

In this lesson, students will be introduced to the concept of using timers for animation. Now instead of having graphics programs that stay the same, the content changes every time the timer runs. The first program students will see is a moving ball, so discussing this with the class as a demo on the projector is very useful.

Objective

Students will be able to:

  • Explain in their own words how animation works
  • Create animation in programs using the setTimer function
  • Explain what a callback function is
Description

In this lesson, we’ll look at more examples with timers and start making more interesting animations. Students will use timers and the Randomizer to create animations on the canvas.

Objective

Students will be able to:

  • Create programs with timers to create increasingly challenging animations
  • Analyze existing programs and explain how they create animations
  • Utilize the Randomizer to generate random events in their animations
Description

In this lesson, students use timers in combination with the other ideas they have learned, including more graphics as well as coordinate math to create different objects. The random ghosts serves as a fun example to show how you can modify things once you have the basic building blocks in place to make them more readable and easier to alter.

Objective

Students will be able to:

  • Explain the general workflow of creating an animation program
  • Analyze animation programs and identify similarities and differences
  • Create increasingly challenging animations using timers, graphics, and the Randomizer
Description

In this lesson, students build on the use of timers and utilize if statements inside timers to dynamically change what the animations are doing.

Objective

Students will be able to:

  • Create increasingly challenging animations that simulate movement using timers
Description

In this lesson, students are introduced to a way input can be taken from the user’s mouse using the mouse clicked method.

Objective

Students will be able to:

  • Describe how events are different than timers
  • Use mouse click events to create programs that respond to user clicks
Description

In this lesson, students learn about lists/arrays and how to access an element in an array with an index so they can create ordered collections of items and use them in their programs.

Objective

Students will be able to:

  • Define an array
  • Access certain elements of an array by using an index
Description

In this lesson, students learn how to add and remove elements at the end of an array using the push and pop methods.

Objective

Students will be able to:

  • Add elements at the end of an array using the push method
  • Remove elements from the end of an array using the pop method
Description

In this lesson, students will be able to get the length of an array and learn how to loop through an array so they can have more functionality with arrays in their programs.

Objective

Students will be able to:

  • Determine the length of an array using the length property
  • Use the length of an array and a for loop to loop through the elements in an array
  • Loop over an array to filter or print certain elements based on tested criteria
Description

In this lesson, students will be able to get the length of an array and loop through an array so they can use arrays in problems involving random numbers and JavaScript graphics.

Objective

Students will be able to:

  • Use the length of an array and a for loop to loop through the elements in an array
  • Loop over an array to filter or print certain elements based on tested criteria
  • Using iteration on arrays for problems involving randomness and graphics