Christopher Fremond
3d7e4d40b2
|
2 months ago | |
---|---|---|
.. | ||
README.md | 2 months ago |
README.md
Transform Objects
Mindful AI mode
Context
Imagine your favorite robot friend with all its cool features: a type, weight, and operational status.
In JavaScript, we use objects to group these properties together, making it easy to manage and tweak our robot’s settings. Let’s see how we can modify, add, or remove properties in a JavaScript object to make our robot even cooler!
AI-Powered Learning Techniques
Contextual Learning Technique: This strategy places learning within a real-world or practical context by having the AI relate concepts to scenarios you might encounter in everyday life or your work. It helps you understand the relevance of what you’re learning and how to apply it.
Find the examples across the subject ;)
Concepts
Modifying Objects
Let's start with a robot object:
const robot = {
points: 0,
code: "75lai78wn",
};
Adding a New Property
Give your robot a name:
robot.name = "RoboMax";
Changing a Property Value
Boost your robot’s points:
robot.points = 10;
Removing a Property
Remove a property:
robot.code = undefined;
Prompt Example
:
-
"Think about your pet. How would you use an object to keep track of its name, age, and favorite food?"
-
"You have a collection of books. How could you use an object to remember the title, author, and how many pages each book has?"
Instructions
Task 1:
Modify the provided robot
variable:
- Add a
model
property with the string value 'RX-78'. - Add a
fullName
property that is the joined value of thebrand
and themodel
with a space in between. (brand
andmodel
are already defined in the providedrobot
) - Add
10
to itsbatteryLevel
property.
Task 2:
Let's move away from objects a bit, and discover a notion we will use later. Duplicating a String with Placeholders
!
Declare a variable duplicate
that repeats the provided variable sentence
, separated by a comma and a space, and then adds an exclamation mark at the end.
For example, if
sentence
is "Hello there", we expect "Hello there, Hello there!".
What a good occasion to apply what you learned in using generative AI and documentations to understand duplicating a string with placeholders! Now you are capable to find the information everywhere;)