Copy and modify
(IDE etc.)
Examples: VSCode, Notepad++ or regular notepad
Web browser like Google Chrome or Mozilla Firefox
In VSCode, you can just write !
and it will autofill the setup for a html file.
If you don't use VSCode or it does not work, you can copy this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
You can create a javascript file in many ways. You can for example create any type of file in your folder/working directory and end it with .js. This can easily be done in VSCode where you can clearly see the file extention (what the file ends with after .).
<body>
<script src="filename.js">
</body>
Open the console by either pressing f12 while in the browser or opening though right-clicking and choosing "show console".
For commenting on a single line:
//
Example:
// hello
For commenting on multiple lines:
Start with:
\*
End with:
*/
Example:
/* asf
hello
world
*/
Create variable with var
or let
and the name of the variable.
var a = 1;
Call upon the variable by just using its name.
a
>>> 1
Change the value of the variable by calling upon it and appointing it a new value with =
a = 2;
Create constant with const
:
const pi = 3.14;
Some types: number
, string
and bolean
:
let numb = 0;
let str = 'abc';
let bool = false;
Arrays are a list of elements. These elements can be any of any type and can be mixed in the array. Arrays can be created to have a fixed lenth or an dynamic length.
A fixed length array is created with const
.
const b = ['a', 'hey', 2, '๐'];
A dynamic array is created with var
or let
.
let c = [2, 3];