You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2.9 KiB

Glance on Power

Brainpower mode

Context

Bravo! You've successfully brought the shape of your robot friend into existence. Now, it's time to take the next exciting step and start building the power to bring your robot to life. Yes, it's time to start thinking like a coder, builder! Using JavaScript, you'll be able to add dynamic abilities and interactions to your creation. Get ready to breathe life into your robot friend!

Ready to start collecting your power through learning to code? Let's go, time is against us!

Concepts

Values

In the coding world, values are like the energy sources that power your robot. There are three types of values that can model the WORLD! (In the end, it's all 1s and 0s for the computer), but for us, humans, we need an easier way of representing things.

We can all agree that 11010001100101110110011011001101111 is not a very friendly way to say 'hello'!

Numbers 🔢

Numbers are like the vital stats of your robot:

  • Whole numbers: 1, 23, 232139283
  • Negative numbers are prefixed with -: -1, -1231
  • Decimal numbers: 3.14, -2.53343, etc.

Use them for quantities like in daily life.

Booleans /

Booleans are the simple true/false logic gates for your robot:

  • Something is true
  • or false

They represent a truth, an answer to a closed-ended question (anything that can be answered with yes or no):

  • Is the robot's battery full? true
  • Is the robot currently charging? false
  • Can the robot see an obstacle? true (most likely)

Strings 🆒

Strings are the commands and messages your robot can use:

  • 'Activate'
  • 'Hello, human!'

A string is a sequence of characters used to represent text. It needs delimiters to define its beginning and end. Delimiters are matching quotes, either `, ", or '.

Using console.log

To display output from a script into a console, use the function console.log:

console.log(); // <- will show an empty line

Add any value between the parentheses to see it appear when the script is executed.

It is very important to use this often to validate that our code is working correctly. The more it is tested, the easier it is to understand what's going on in the code!

In doubt, console.log everything, don't be shy, they are free.

Instructions

To do this exercise, use the code editor on the right side of your window. In the hello-there.js file, code a program that displays:

  • The exact text Hello There!
  • Any Number (like the robot's serial number)
  • And a Boolean (indicating if the robot's sensors are active)

Don't forget to test your code before submitting it, using the Run button.

Recommendation

Videos designed to give hints are assigned to each quest. It is strongly suggested to watch them as you go.

Resources