Do you wanna learn JavaScript within three days?
Beginners guide
JavaScript is the basic for developing web pages rather than HTML & CSS. It is used mainly for enhancing the interaction of a user with the webpage. In other words, you can make your webpage more lively and interactive, with the help of JavaScript.
This is a scripting language as it cannot be run on its own and need a help of browser.
You should place all your JavaScript code within <script> tags (<script> and </script>) if you are keeping your JavaScript code within the HTML document itself.
Write your first program:
Declaration of variables in JS
var can be used whole over the program. let can be used within the scope where we needed. const cannot be changed through the whole program.
This is a simple program done by declaring variables. So the output will be like this..
How to use conditional statements
Conditional statements are used to decide the flow of execution based on different conditions. If a condition is true, you can perform one action and if the condition is false, you can perform another action.
There are mainly three types of conditional statements in JavaScript.
- If statement
- If…Else statement
- If…Else If…Else statement
If statement
This can be used to check only specific condition.
To check, if the person is adult or not, we can use if statement. And the output will be:
If…Else statement
If you have to check two conditions and execute a different set of codes you can use this.
The output will determine by the compiling time of user.
If.. Else If.. Else statements
You can use If….Else If….Else statement if you want to check more than two conditions.
User input will determine the output of the program.
Conclusion
Here we learn how to code by declaring variables, and how to use the conditional statements according to our necessity. In my next blog you can find how to use loops and arrays.