- Truffle Dog Digital newsletter
- Posts
- Running a One-Line Program Directly in Your Browser
Running a One-Line Program Directly in Your Browser
Your browser (Chrome or Edge) doubles as a coding tool—learn JavaScript instantly.
Open Dev Tools, type a simple one-liner, and see the magic of code in action.
No software, no setup—just you, your browser, and the power of programming.
You might not realise it, but your Microsoft Edge or Google Chrome web browser (the thing you use to visit websites) is a great playground to learn the basics of coding. It's super easy to run one-line programs and get a feel for what coding actually is.
This is one of the steps we go through with our apprentices in the early days because it provides instant gratification, and you don't need to download any specialised software. In reality, you're using the same approach to coding as every application you've used on the internet since the late 1990s.
Step 1: Start with a Blank Page
To get started, open a blank page in your browser. Simply type about:blank into your address bar, and you'll see something like this:
Step 2: Open Developer Tools
To run code, you'll need to open a tool called "Developer Tools" (or "Dev Tools"). This is as simple as pressing:
Control + Shift + I (Windows)
Command + Shift + I (Mac)
You'll see something like this:
Your screen might look a little different initially, but don't worry.
Step 3: Open the Console Tab
Now click the "Console" tab at the top of Developer Tools. Your screen will switch to this view:
Now you're ready to type (or copy/paste) some code!
Step 4: Run Your First Code
At the prompt (the > symbol), type or copy/paste the following code:
console.log("You entered: " + prompt("Enter some text, I'll repeat it in the console"))
Then press Enter.
You should see something like this:
Then, after entering some text, you'll see this:
Congratulations!
You've successfully written and run a program in JavaScript—the programming language of the internet! This simple exercise is a great way to get started and understand the basics of coding.
Andrew Walker
Technology consulting for charities
https://www.linkedin.com/in/andrew-walker-the-impatient-futurist/
Did someone forward this email to you? Want your own subscription? Head over here and sign yourself right up!
Back issues available here.
Reply