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
-
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.
-
Optional Alternative:
Task 2: Write a JavaScript Script
- 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!");
- Create a file named
- 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.
- Modify the greeting to include your name (e.g.,
Task 3: Execute Your Code
- 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.
- If working locally, create a simple HTML file that includes a script tag referencing
- 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.
- Submit the
- 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
Criteria | Points | Description |
---|---|---|
Correct Console Output | 10 | The script prints “Hello, JavaScript!” exactly as specified using console.log() . |
Environment Setup and Execution | 5 | The script is executed successfully using the browser console or an online editor without errors. |
Code Quality and Formatting | 3 | The code is free of syntax errors, follows proper indentation, and is easy to read. |
Enhancements | 2 | Credit if the script includes personalization (e.g., including the learner’s name) or additional output. |
Total Points: 20 points
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.