Skip to Content
Lab 1

Getting Started with JavaScript

Overview and Objectives

In this lab, learners will set up their JavaScript development environment and write a simple script to output a greeting message. This activity is designed to build confidence in running JavaScript code, using the browser’s developer console or an online editor. By the end of this lab, learners will be able to:

  • Understand the basics of a JavaScript programming environment.
  • Write and execute a simple JavaScript script.
  • Use the browser console to display output.

Tasks and Instructions

Task 1: Environment Setup

  1. Access the Developer Console:

    • Open your preferred web browser (Chrome, Firefox, etc.).
    • Open the developer tools (press F12 or right-click on the page and select Inspect).
    • Switch to the Console tab.
  2. Optional Alternative:

Task 2: Write a JavaScript Script

  1. Create the Script:
    • Create a file named hello.js using your local text editor, or open a new project in your online editor.
    • In the file, write a script that uses console.log() to output the message:
      console.log("Hello, JavaScript!");
  2. Enhance Your Script:
    • Modify the greeting to include your name (e.g., "Hello, JavaScript! I am [Your Name].").
    • Add an additional output message to show another greeting or fun fact.

Task 3: Execute Your Code

  1. Local Setup:
    • If working locally, create a simple HTML file that includes a script tag referencing hello.js. For example:
      <!DOCTYPE html> <html> <head> <title>JavaScript Lab</title> </head> <body> <script src="hello.js"></script> </body> </html>
    • Open the HTML file in your browser and view the output in the developer console.
  2. Online Editor:
    • If using an online editor, run the project to see the output directly in the editor’s console.

Submission Criteria

The following should be included within a GitHub repository, and submitted via Canvas:

  • Files/Links:
    • Submit the hello.js file (and HTML file if working locally) or provide a link to your online editor project within a README.
  • Output Evidence:
    • Include a screenshot showing your code along with the output in the browser console.
  • Error-Free Code:
    • Ensure the script runs without errors and the output exactly matches the required greeting message.

Grading Rubric

CriteriaPointsDescription
Correct Console Output10The script prints “Hello, JavaScript!” exactly as specified using console.log().
Environment Setup and Execution5The script is executed successfully using the browser console or an online editor without errors.
Code Quality and Formatting3The code is free of syntax errors, follows proper indentation, and is easy to read.
Enhancements2Credit if the script includes personalization (e.g., including the learner’s name) or additional output.

Total Points: 20 points

Note

Partial credit will be awarded for submissions that demonstrate a correct understanding of the core objectives even if minor syntax errors or formatting issues are present. For example, if the script outputs the correct message but has minor indentation problems or missing semicolons (where not required by the runtime), partial points will be awarded. If the script fails to run due to errors, a clear explanation or evidence of debugging attempts may earn some partial credit.