Coding Skills You Will Learn In Episode 3

Hi HACK family,

In episode three, Lightspeed will build upon your understanding of functions and introduce Javascript concepts such as objects and properties. Meanwhile, Fizzics will challenge your problem-solving skills as you think about new ways to complete levels without your handy tools. Let’s jump right in and get started.

Lightspeed
In Lightspeed level eleven, you will be introduced to objects and properties in Javascript.



What is an object?
An object is a set of instructions (or blueprint) to build something, let’s say a Lego 🛳️ship. The instructions are provided by the manufacturer (Lego) for you to make the Lego ship. You can create an object by using “let objectName = { }” (see the image below).

What is an object’s property?
Each Lego ship has its own characteristics such as the number of doors, the length of the ship, the color of the ship, the name of the ship, and more. These characteristics are called properties. An object’s property has a name (numberOfDoors) and a value (2).

How do I set a property of an object?
If you want to set the number of doors for the ship, you would say something like:

“Ship” is the object
“numberOfDoors” is the name of the property
2 is the value assigned to the name of the property

You can assign all sorts of fun properties to an object (see image above). To access the object’s property value, the format is objectName.propertyName or in this case “ship.numberOfDoors”. Cool, right?!

- - - - -

Fizzics
In Fizzics, you will use everything you’ve learned about gravity, attraction, radius, and more to finish tasks without the use of your handy tools.

Here’s a handy Hack Toolbox cheat sheet (see image below):
  1. Attraction: A positive attraction value will pull your object closer to another object and increasing its speed. If your ball has a positive attraction for a diamond and your diamond has a positive attraction value for your ball, the two will attract one another as they move closer together. A negative attraction value will push other objects away and decreasing its speed. Think of it as a force shield.
  2. Bounce: A high Bounce value will make your object more bouncy and a low Bounce value will make the object less bouncy.
  3. Friction: The higher the Friction value, the quicker the object will slow down over time. A zero Friction value will allow the object to maintain speed indefinitely while it's moving.
  4. Frozen: A frozen object will not move.
  5. Gravity: A positive Gravity value will move the objects to the bottom of the screen and a negative value will move the objects to the top of the screen. The higher the value, the faster the object will move.
  6. Radius: A positive radius value will increase the size of an object and a negative radius value will decrease the size of an object.
Hint #1: For most tasks, you are not required to collect all of the diamonds to complete the level. If you are stuck, try to complete the level without collecting all of the diamonds. When you have completed the storyline, you can reset the quests and shoot for a top score. For instructions on how to reset Fizzics, check out this awesome video from hacker Hyan here.

Hint #2: You may need to change multiple variables, such as gravity and friction, to complete a level. If you’re not sure what to change, just keep on Hacking. Click the “reset all” button at the top left corner of the Hack Toolbox to start over with a clean slate.

Hint #3: If your ball is still moving, click on it and the ball will immediately stop moving.