Home
Definitions Lesson - Step By Step Instructions
- Open/Create the new files using Visual Studio Code.
- definitions.html
- definitions.css
- definitions.js
- My preferred VSC layout is 2 by 2, Click on View, Editor Layout and select Grid 2 X 2.
- Place one file in each of the windows leaving one open window for playing with sample code, etc.
- At this point your screen should look link the one in the video.
- Link and test your links
- Link your definitions.css file to your definitions.html file.
- Test your css file link by...
- Link your definitions.js file to your definitions.html file.
- Test your js file link by...
- Add your html by copying my code.
- If necessary, Add your css by copying my code.
- Open, goto your definitions.js file so we can add a few sample definitions. Here we are going to create our data in JSON format.
- If you are new to JSON it is better to copy some existing JSON and modify to your needs.
- This way you are less likely to have a syntax issue.
- Now lets test our JSON using console.table(definitions);
- Now lets test our JSON using console.log(definitions);
- Be sure you have the Google Chrome Console open. F12 or right click and select inspect.
- Make note of the difference between the way console log and console table show your data. Both have their advantages when debuggine your code.
- Now lets use console.log to see how many definitions we have in our array.
- Remember our const "definitions" automatically inherited some methods when we made it a reference to our array of JSON data. One of those methods was length. Now we will use
the length method to tell us how many items are in our array.
- We will use the same console.log we used in the previous step, but will add the method length.
- In your Google Chrome Console, you should have an integer that represents the number of items in your array.
- Get the steps from the definitions.js file and merge with this file.