Exercises: Objects 4 - Modifying Properties

About this lesson

change the value of properties within an object

Concepts Reviewed:

Object Property Access
Information
Step 1
Functions & Objects

The code below declares a function which takes a creature object as a parameter and will be able to apply a change to it.

Temp1524172672 Temp1527198243
Information
Step 2
Applying a function to an object

This line applies the code of the heal function with jamikazam as the creature.

Temp1524172746

This must be called after both jamikazam and heal have been declared!

Temp1527198360
Information
Step 3
Example

This function halves the attack values of any creature you wish to spook

Temp1524172973

In this case, we spook jakodude

Temp1530914315
Challenge
Step 4
(40 PTS) Create a heal function

It should add a set amount of HP ( I did 20 ) to a creature.
A creature should not be able to exceed it's maxHP.

Temp1530914098 Temp1530914041 Temp1530913683
Exercises: Objects 4 - Modifying Properties Info

Account

MVCode Clubs

Created By

Missing tiny jake wheaton

Course:

Exercises: Objects

Access Level

premium

For Teachers and Schools

Teach coding to your students with MVCode Teach

MVCode offers an integrated product designed to teach coding to students.

Learn more about MVCode Teach