Skip to main content

Getting Started with Code on a Chromebook

Chromebooks are amazing devices! Combining security with ease of use, they provide a uniquely Google experience you can't get anywhere else, not even with Android (Although the Pixel phones are getting close 😉).

One of the great capabilities of a Chromebook is the ability to code useful programs out-of-the-box.

In this article I will show you how to get started with writing JavaScript code on a Chromebook, and completely offline to boot!

To get started make sure you are logged in and have a new tab open. Now press Ctrl+Shift+i to open the developer tools. In the panel that opens there will be a series of tabs along the top. Click on "Console" tab to bring up the JavaScript terminal.
The Javascript Console!
You will see a line with the little right-pointing arrow, this is your input line. From here you can create and call variables and functions. So lets create our first variable. Go ahead and type in the following and press enter.
  1. var a = 5;
You will see a line that says "undefined" after you press enter followed up with a new input line. That "undefined" is the return value of entering the line of code. In this case it just means that it worked correctly. Depending on what you enter you may get something else back, but we'll get to more of that later.

To check on the value of a variable that has been stored you can type the name of the variable and press enter, and it will return the current value of that variable. Go ahead and try that now.
Input and Output
Now that we have a stored value lets mutate(change) it. Type in the following and press enter.
  1. a = a + 5;
Mutating Variables... Cool!
You'll notice that the return value is colored blue. This indicates that the variable is a number, you know, something we can perform math operations on. Another variable type is called string. Strings are basically text. Strings will be colored red and surrounded with quotes
in the output.

So lets say we want to convert our 10 from a number to a string. How can we do that? Fortunately Chrome(and any browser for that matter) comes pre-loaded with a ton of what are called "convenience" functions. These allow us to preform common tasks to mutate variables and interact with the Chromebook, and one of these allows us to do the conversion we want. So try the following line of code and see the result.

  1. a = a.toString();
Number to String
So that's just a couple of things to get you started. I'll add a couple of links below to additional information about the basics of JavaScript.

In future articles I will talk about how to save your code and work with HTML and CSS.

Let me know in the comments if you have any questions or suggestions.

JavaScript Primitives
JavaScript Expressions and Operators
Built-in Browser Functions