How to Make a Basic JavaScript Quiz
Making a game with JavaScript can be fun and satisfying as well as a bit of a puzzle. The code in the this article is one way of making a game using JavaScript. Once you know the basics, feel free to adapt and play around with it. Set up...
Part 1 of 5:
Setting Up
- Set up your programming environment. You will need a text editing program to write your code in. You can write it in a notepad document but you will probably want an editor designed for programming such as Notepad++ (Windows), Atom (Mac) or Notepad (Linux). However any basic text editor does work.
- Create the files you need. You will need two files: one in HTML that is read by the browser and one in JavaScript that is the game.
- Set up your files and folders. Because you only need two files, you don't need any sort of complex filing system. As long as the two files are in the same level of the same folder it will work. So save both of your files in the same place.
- To save as html add a .html extension. Us a .js extension for the JavaScript file.Set up code in your files. The JavaScript file requires no setting up but the HTML does. In your HTML document add the following code:
<html> <head> <title>Page Nametitle> <script src="quiz.js">script> head> <body> body> html>
- This is the basic set up for almost any page in HTML.
defines the code as HTML to the browser.
tells the browser that everything in that section is written in HTML unless specified otherwise.
is a section that holds information about the page such as the title.
is the name that shows up in search results and the name on the tab.
- To save as html add a .html extension. Us a .js extension for the JavaScript file.Set up code in your files. The JavaScript file requires no setting up but the HTML does. In your HTML document add the following code:
Update 05 March 2020
You should read it
- Basic examples of HTML
- Why write neat and organized HTML?
- Computer code element in HTML
- HTML editor online
- 17 simple HTML codes you can learn in 10 minutes
- 5 free online HTML editing tools that test the best code
- Introduction to HTML
- HTML color code - color code table in html
- HTML ISO Country Code Reference
- How to Build a Calculator with HTML
- Standard format and code coding convention in HTML5
- 5 steps to learn a dynamic HTML web component profile
Maybe you are interested
Database Monitoring Services: Keeping Your SQL Server in Check How to run VM on Raspberry Pi using Proxmox Mysterious black objects appear in NASA sun photos 10 strange and interesting facts about the universe you may not have heard of The interesting scientific knowledge that we missed while at school What bad thing will happen if the Sun suddenly disappears?