1. Getting to Know JavaScript
Activity 1.01: Creating an Alert Box Popup in the Web Browser
Solution
- Press F12 to open the developer tools that are integrated within it. If this doesn't work, a right-click may expose a prompt so that you can do this as well:
- The developer tools may default to the console. If not, there is likely to be a
Console
tab you can click on to activate it. The console allows you to write JavaScript code directly within the web browser itself: - Within the console, write the following command:
var greeting = 'Hello from JavaScript!'; alert(greeting);
- Hit Return/Enter to execute the code. The code will execute within the browser environment.
You should see an alert appear in the browser viewport displaying your message, as shown here:
What does...