Lab-1-1
(4% of the course mark)
Node.js Lab
- The first Node.js lab introduces learners to the fundamentals of server-side JavaScript development. Through hands-on exercises, participants gain an understanding of setting up a basic Node.js environment.
Lab objectives
-
Understand the basics of server-side JavaScript development.
-
Set up a Node.js development environment on your local machine.
Create basic Node.js app
-
Open VSCode and create a folder named First-Node-Js-App.
-
Open the terminal and change the directory to First-Node-Js-App.
-
Initialize the app by typing the command below:
npm init
- For now keep on pressing enter to accept the defaults.
Use the command below to accept all defaults and skip the individual prompts.
npm init -y
- Create a file named index.js and enter the following code.
console.log("Hello World");
-
Save the changes.
-
On the terminal enter the command below and press enter.
node index.js
- Capture a screenshot of the terminal output and name it node-js-hello-world.png.
Modify basic Node.js app
-
Modify index.js and implement the specifications below.
-
Create a constant JS object variable named person that has the following properties.
firstName
lastName
An array of artists which has artistName and songName
- Create a function named displayData with the following specifications.
This function will accept the constant variable person created on the previous step.
This function will display firstName and lastName from the constant variable.
This function will display the contents of the artists array using a loop.
-
Save the changes.
-
On the terminal enter the command below and press enter.
node index.js
- Capture a screenshot of the terminal output and name it node-js-hello-world-modified.png.
Using sakura.css and normalize.css
-
Open VSCode and create a folder named app.
-
Download the files sakura.css and normalize.css to the app folder. Make sure to rename then to sakura.css and normalize.css.
-
Copy node-js-hello-world.png and node-js-hello-world-modified.png to the app folder.
-
On the app folder create a file named: lab-1-1.html and copy the HTML code below.
<!--
Developer:
Purpose:
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Update title -->
<title></title>
<!-- Reset styles using normalize -->
<link rel="stylesheet" href="./normalize.css" />
<!-- Classless css -->
<link rel="stylesheet" href="./sakura.css" />
</head>
<body>
<!-- Enter the HTML codes to display the captured screen shots -->
</body>
</html>
- For each screenshot implement the HTML codes to display a title, short description, and screenshot image.
Submission
-
Create a folder named submit.
-
Copy the First-Node-Js-App and app folders to the submit folder.
-
Create a zip file of the submit folder.
-
Navigate back to where the lab was originally downloaded, there should be a Submissions section (see below) where the zip file can be uploaded.
