Learn to Code via Tutorials on Repl.it!

← Back to all posts
✨✨Basic JavaScript Tutorial✨✨
KfirHarif (1)

JavaScript Tutorial!

Hi person who is reading this tutorial! Thank you for clicking on this boring fun tutorial! As you have seen (if you had any common sense) this is a JavaScript tutorial and I'm gonna teach you some of the basics of JavaScript!


Ok! So, to make a comment all you have to do is write two slashes (//) and put what you want to write in your comment after that!

// This is a comment!
// This is another comment!

For multi-line comments, you have to put a slash and a star to start the comment and to close it you have to put a star and then the slash.

Dear Mr. Guy-Who-Made-This-Tutorial,

I would like to thank you for showing me how to comment in JavaScript and I would also want to thank you for making this fun!

   Mr. Guy-Who-Read-This-Tutorial 😀

Comments don't have an output because they are just text in your code.


Ok, so if you know some Python, then you might know that to write something in the console you have to write print("what you want to write"). But in JavaScript you have to write console.log("what you want to write").

console.log("Hello World!");


Hello World!

You can also put in numbers in a console.log(); sentence.




Every JavaScript line has to end in a semicolon (;).


So strings are just what they sound like; strings of characters! Strings always have to be enclosed in either double quotes ("") or single quotes ('') but they can't be mixed like this: 'this is a string" or like this: "this is a string'. This is an example of the right way:

"this is a string"
'this is also a string'

I wanted to go over strings because they are very important when you want to write something or sometimes give a value to something.


Variables are things that can store bits of information in them. In JavaScript, to announce to the computer that you want to make a variable, you have to write var. Then after you write var you put a space and then you can write something like age and that will be your variables name. After you name your variable, you have to put a space and then an equal sign (=) and then another space. When you do that you have to write in a value for the variable. If you want your variable to be a number, then just put in that number. If you want your variable to be a string, then you need to put in either double quotes ("") or single quotes ('') like we talked about earlier in the "Strings" section. The entire format is shown below:

var variable_name = number; // This is for numbers
var variable_name = "some text" // This is for strings
var variable_name = 'some other text' // This is also for strings

This is an example of announcing some variables and printing it:

var myNum = 10;



Notice that when I put the variable in the console.log(); statement, I don't use any quotes.


The document.write(); statement is basically like console.log(); except that instead of printing something in the console, it writes something in your document.

document.write("Awesome stuff!");


Awesome stuff!

Just like the console.log(); statement, you can put a variable on it.

var myVar = "JavaScript is awesome!!!";


JavaScript is awesome!!!

Multiple Variables

This is gonna be a very small section and I decided to squeeze it in. I wanted to tell you that you can declare multiple variables in one line if they are the same data type.

var myNum1 = 1, myNum2 = 2, myNum3 = 3, myNum4 = 4, myNum5 = 5;
// Declaring multiple number variables

var myVar1 = "HI", myVar2 = "hi", myVar3 = "Hi", myVar4 = "hI", myVar5 = "hi!"
// Declaring multiple string variables

Since I didn't print the variables, there is no output

Bunching Together Strings And Numbers