 Hello everyone, welcome to my course, Fundamentals of JavaScript, Road to JS from HTML. This course will be very, very useful for you, especially if you are new to computer programming and so on. And this is actually a foundation course on JavaScript, so you're going to see only the basic ideas on JavaScript, how to write a code in JavaScript, what are the basic syntax we have in JavaScript, and so on, so up to some extent we'll discuss. Then that is a code given here, Road to JS from HTML. How they are connected, HTML and JS, this is the first thing that we are going to see in this lecture. Let us go on. In this, for the topics to learn, a quick summary on HTML, let us have it and relation between JavaScript and HTML. The need for JavaScript, the general syntax, they use how to get output and how to give user input in JavaScript variables, so what are the, how to declare those variables in JavaScript and how to do operations on that, I'm sorry, how to do operations on those variables, mathematical operations or any kind of operation, comparison operators. If you are already good in programming, this is just a very easy course for you to learn. We are going to see data types, what are the different data types available in JavaScript and how to utilize that, if statement, if statement, for loop and while loop. These are the basic things that we are going to see in this course. Maybe in further courses we can see in-depth about JavaScript. JavaScript is really vast like an ocean, so you can swim through the ocean to get more knowledge. Let us have a comparison between HTML and JavaScript, how they are really connected. HTML means it's an hypertext markup language. It's usually designed, the outline of the web pages. It's actually used to design the outline of the web pages, how they are designed. For example, let us say if you go to Google, how the web page is designed. There will be a large name showing Google, there will be a dialog box, and there will be a search box. Google is actually basically a search engine, so there will be a search box for us to search anything in Google. How to design that? Please understand that your web pages, maybe your college website, whatever it is, it is actually designed in HTML, using HTML code. And cascading style sheets. The name suggests it is adding styles to our web pages. It adds more beauty to our web pages. It enhances the nature of the pages. You can add some designs, images, animations, transitions, whatever you like using CSS. So if you are learning HTML and CSS would also be helpful for you. And everything in HTML will be placed inside tags and we will see the basics in tags. We are not going to see much deeper. We will see a basic syntax on how HTML should look like. Then JavaScript is a scripting language. Please understand the difference. This HTML is actually used to design the outline of the web pages, where JavaScript is used to make the web pages function. For example, let us say if you have a button in a web page, like submit or login, if you have like that, that button is actually designed using HTML. It is written in HTML code. But if you click that button, your information should be saved. It should be directed to another page. Or you should be prompted. That is, you have submitted successfully. You should be alerted. That is actually done by JavaScript. So what it should do? What the web pages should do? It is actually directed by the JavaScript. So it is scripting language. It is used to control the web pages. A lot of different input functions are there. There are a lot of functions. I already told you that JavaScript is an ocean. So there are a lot of input functions. We will see some of the functions, very basic functions in this course. This is the fundamental course. This is the bridge course. Then JavaScript is a lightweight programming language. It can classify programming languages into lightweight, which is easy to learn and hard to learn. I mean, it is not hard. You can say it is challenging. JavaScript is an easy language to learn. So one more point I want to insist here is, there is no relation between Java and JavaScript. JavaScript is completely different from Java. Except the name Java. JavaScript only has the name of Java. But don't confuse yourself. Java is different and JavaScript is different. This is scripting language. Let us understand the difference using this cell phone. It is an analogy. Don't confuse. If you take the cell phone, one might have designed the buttons, settings button, the camera option, the logo for the camera, and the logo for this app, this application, whatever it is. But if you click this camera button, the camera automatically, the camera should work. The system should make the camera work. That code is actually written using can be compared to JavaScript. And this button designing can be compared to HTML. So designing is all about, HTML is all about designing and JavaScript is all about functioning. That is the analogy I have been trying to say. So in this next lecture, we are going to see about the basic syntax of HTML. Thank you. Hello everyone. In this lecture, we are going to see how to write an HTML code. And we are going to run the code in our browser. I am going to check whether it works or not. Most of you might have learned HTML in your elementary school itself. It is a very easy programming language. So you might have learned. So you guys have a refresher or a recap. And some might have, you know, have not learned it. So let us try to write a code in HTML. And the editor can be anything. Editor can be any normal, you know, software, a typing software, maybe a notepad or Microsoft Word, anything. So let us search here. Let us use notepad, which is very, very easy to use. I have opened the notepad. Let us maximize it. Let us, you know, zoom it. It will be clear in the video. So recall that or understand that HTML code should be written in tags. The keywords are known as tags. So you have an opening time somewhat look like this HTML. Everything should be included in this tag. Everything should be typed inside this tag. And the tag should be... Sorry, sorry. I am sorry, guys. The tag should be closed like this. So this is the opening tag and this is the closing tag. And inside this, you can write your code. Inside this, you can use any number of tags to, you know, enhance your web page. So the code for web pages should be placed inside here. So let us write a code, HTML. Then inside, when you write HTML, it means it is HTML code. So that's why I am mentioning the tag HTML. There are a lot of tags in HTML. You might be knowing it. So let us rush up HTML. Generally, people use body tag to print something in web pages. So the body of the page should be designed here inside the body tag. So let us move this body. Let us type hello world. Hello world. Fine. Let us close this body tag. We have to close this body tag. It will work properly. And close the HTML tag. The tags will also be included like head tag, title tag. I will tell you why. This is enough for an HTML code. Then after you are clear with it or you are done with it, you save it. Let us save this somewhere. Let's stop. There is a new folder here. Let us save this. Let us save it as my lecture one. The extension is .html. You should not save it as text. Then it will not display in browser. It is extension.html. So you can lock all files here. My lecture one .html. This is very, very important. This extension is .html. Then save the file. Let us go to the folder. Let us check our file. Our file is here. Let us click it and open it with a browser. I am using Microsoft Edge. There it is. It is our output. Hello world. This is my Microsoft Edge browser. This is in my web page. Hello world. Whatever I have typed in the source it is in my web page. This is my source code. This is my output. This is in my web page. Browser. You can type anything here. There are other tags also. Some other tags. There is a tag called title tag. Title my web page. You should have my web page. You should close the tag here. Whenever you open a tag close it. You should close it. Plus control is to save. I am moving the right. Sorry not save. You should save the file. Open the browser. Refresh it. Whatever changes you have made to the source code will be reflected here when you refresh the file. Refresh it. I have removed hello world. Hello world has vanished. Title tag is here. Let us close these two web pages. Title tag is here. I have put the title as my web page. It is shown here. This is my title. There are other tags also. Inside body I can use that. Maybe h1. H1 is a tag to enhance the sentences. H1 is a tag. I have typed hello world. Let us save this. Go back to the browser. Refresh. You can see the difference. It has been bolded. The font size has been increased. We can use that. One more favorite tag. A lot of tags. I have one favorite tag. It is my favorite tag. You can serve through the internet to use these tags. Let us save this. Let us go for the browser. It will actually roll on the web pages. It is my favorite tag. You can control it using code. Whether it should roll from right to left or left to right or up to down vertically. This is how you write the code for the web page. Everything should be mentioned inside the tags. This is pure HTML. In our next lecture we are going to see how to write a JavaScript here. How to write a JavaScript code here. That is what we are going to see in the next lecture. Thank you. In this lecture we are going to write our first JavaScript code. How to print something. Let us print hello world using Java. In the previous video we have printed hello world using HTML. In this video we also use HTML. JavaScript will be embedded inside the HTML code. JavaScript will be embedded inside the HTML. This is the point you have to understand. Let us start with HTML. I can zoom this right. HTML then open the body tag. Let us close the body tag. I will just observe what I am doing. Let us close the HTML tag also. This is the basic HTML structure. You have opening tags and closing tags. If you execute this code nothing will be printed on your web page. To differentiate the HTML code and the JavaScript code the JS code will be placed inside these two tags. Whenever you write something in between these two tags you are writing JavaScript code. The JavaScript code is actually embedded inside the HTML. I hope you are clear. Let us print something. Normally to print something we use a function in JavaScript that is document.write Whenever I write document.write whenever I type it means that I am going to print something. You have to open the place and type something here. Let us write hello world. Let us close this. You have to put a semicolon. The semicolon means that the statement is over. The statement is ended. This denotes the end of the statement. All the statements in JavaScript will end with a semicolon. Document.write This is a function used to print any statement here. You should print some statements in your web pages. Save as lecture number 3 the extension is .html and I have explained this in my previous video. Let us go to the file and open it. Let us try to open it. It has printed. If you remove this function let us go to the source. This is the source. In the previous lecture or video we do not have script tags and we just wrote hello world inside the body tag itself and it has printed hello world. But here if you do not use this function it will not work. For example let us remove this function document.write Let us use it as hello world. Let us check whether it will print or not. Let us save this and go to the browser. The code is actually wrong. In JavaScript if you want to print something you have to use document.write document.write To get user output you have to use this function document.write This is your first JavaScript code. In the next lecture we will see how to declare the variables and the variations on variables. Thank you. In this lecture we are going to declare variables. How to use variables in the JavaScript. Let us search notepad We normally use notepad in our lectures. Let us go for notepad. Here it is Let us do the basic structure of html body then script tag Our code must be placed inside our script tag because whenever I write script tag it means it is a JavaScript. This is how JS is embedded inside html. I will explain that in the previous video also. Let us declare any variable We have to use one function one keyword like var var x Anything Let us write var x This var means the short form of variable. This is the keyword to represent x is a variable. Anything you can write here but it should not start with a number. The variable name should not start with a number. I can say where the variable name is actually a book. I can say abc and underscore is allowed. This is also a variable name but the variable name should not start with a number. This will throw an error. In JavaScript the browser will not show any error. If you have a syntax error in your code it will not print anything. It will give you a blank page. Using that you should understand that there is an error in your code. Let us write var x which means that variable x equals 5. To assign some values to our variable we use this equal to If you mention like this 5 will be stored in x Let us put a semicolon to end this statement. To print x we use document.write x Let us put a semicolon. Let us close the tags. Script tag should be closed. Body tag should be closed. Then html tag should be closed. This is our complete code. Let us save this as variables. .html Here you put all files. That is not a problem but anyway let us open this with a browser. So 5 is printed. Why it is 5? In our source we declared a variable called x. We assign the value 5 to x and we try to print the value of x. So 5 is actually printed. In this way you can do anything in this. Let us say variable y its value is 5. There should be any value. Let us add these two variables. x plus y equals z which means x plus y will be done. That means 5 plus 10 will be added. Then it will be stored in z. Let us close this and try to print the value of z. So two variables are declared x is assigned 5 and y is assigned 10. Then z is assigned x plus y which is 5 plus 10. So it should be 15. Let us take whether it is printing 15 or not. Let us save this code. Save this code using controllers or I can save this. Then go to browser refresh the code. It will show 50. So mathematical operators will work here. I will explain all the mathematical operators in this video itself. It is not a problem. Let us go to the source. You can also subtract it. Subract it. Save the code. Go to the browser. You will get minus 5. Because 5 minus 10 is minus 5. You can subtract it. Then you can also multiply these two values. Save this. Go to the browser. Refresh. Then you will get 50. Where 5 into 10 is 50. You can also divide that value also. Divide. That is two divisions. It is Let us x slash y. Let us check what it returns. This is important. Let us take what it returns. C In most of the programming languages or in C, if you do this or x divided by y it will return only the you know quotient. But in JavaScript it returns the exact division value. 5 divided by 10 is actually 0.5. It returns the exact value of the mathematical operation. So, is it this x slash y will divide these two values. So, that is what I am trying to say. The math operators will be very useful in doing the programs. And there is another operator called modulus operator. That also can be used. Let us save this. This is simple for modulus operators. The other person is simple. Then 5 divided by 5 modulo 10 will be done. It is actually 5. Let us go to the code. 5 divided by 10. 5 modulo 10 is actually 5. So, 5 will be stored and 5 will be printed. So, you have the increment operator also. Let us use the increment operator. To increment operators actually unary operator. So, you need only one variable. One variable is enough. So, let us use the x plus plus. Then let us try to print x. So, let us save this code. Let us go back to the browser. Refresh it. It will print 6. Because what will happen? 5 will be assigned to x and x plus plus is actually means you are trying to print x is equal to x plus 1. This is actually equal in 2. x is equal to x plus 1. Which means increment the value of x by 1. So, 5 plus 1 will give 6. So, 6 will be printed here. This is another operator. Mathematical operator which you might be using in your code. So, that's all. In our next lecture, let us see how to get user input in JavaScript using JavaScript. Thank you. Hello, guys. I welcome you all to lecture number 5. So, in this lecture, we are going to see how to get user input in JavaScript. So, have a note here open and let us get the user input. So, I will follow the basic HTML syntax, HTML, body. Usually, the script tag will be placed inside the body and alternatively, it can be placed in title tag also. That is another tag. Head tag also. Not title tag. In the head tag also you can place the script. It will be working. So, inside the script, we have to write a java code. So, let us declare a variable to store our input. Let us say where var x. Where is the keyword to declare a variable we have seen in that in the previous video. So, the function which is used to get the user input is actually window.prompt which it will prompt the user to give the input in the web page. window.prompt and you have to write like this. Enter a number, maybe. Enter a number. You put a semicolon to enter statement. So, window.prompt whatever you give here will be prompted to the user. And there will be empty box for the user to give the input. So, let us print the value of x. Whatever user types inside the box should be printed. So, let us print that. Using document.write. We have seen that. Let us close the script tag. Let us close the body tag. Let us close the HTML tag also. These and all should be done. Then save this. Let us go to the file and open it. Once the web page is open it is our prompt box. It says enter a number and enter a number. Let us say 8. I am entering 8. I am pressing ok and 8 will be printed because what it happens if I press 8 will be stored in x and that will be printed using this function. document.write. This is the basic code to get the user input. In my next lecture I will explain how to use some other operators comparison operators logical operators. So, thank you. That is all. Hey guys, I welcome you all to lecture number 6. In this lecture we are going to see the types of data types in JavaScript. It is actually very easy concept. So, the different types of data types in JavaScript is actually three. One is integer, another one is floating point number and another one is actually string. So, let us try to illustrate that. Let us say variable phi is equal to x. If you print, if you write document.write in say bracket x it will print it. So, phi is actually an integer. So, that will be understood by the compiler. So, phi is actually an integer but you do not have any separate keyword for integer, float and string. The keyword is actually variable. To declare any variable the keyword is actually var var. So, let us try to illustrate the floating point number 50.09. If you use this decimal point then it is actually a floating point number. Let us save this code. Let us go to the browser, refresh T. 50.09 is actually printed. What I mean is this is a floating point number. It is not integer. So, let us go for the another data type which is string x is equal to let us print hello, how are you? This is actually a string hello, how are you? Let us save this code and go to the browser. I will print hello, how are you? This is string. This is actually a string. This is another data type in JavaScript. If you are good in programming language then these and all might be knowing already. So, I am sorry to explain and let us write another string. How are you? Yes, I am fine. Let us try to put a semicolon. Let us try to put x plus y. Let us see what happens. Let us save this. Let us go to the browser. Hello, how are you? Yes, I am fine. What happens is if you write like this, x plus y then these two strings will be concordinated. That is in simple words these two strings will be added. Hello, how are you? Yes, I am fine. These two strings will be added. If you simply you can add this by using this plus operator. This is available in Python also. Yes, this is actually a string data type and there is another data type also called boolean data type. So, I forgot to mention that. I am sorry. There is another data type also boolean data type. So, the value of boolean data type is actually true or false. There are only two values either it is true or false. So, you can declare like this x is equal to true and which means that if you put like this, if you put variable x is equal to true then this is actually x is a boolean data type or x is of type boolean. So, there are four data types in JavaScript actually. One is integer, floating point number, string and one other one is boolean or another one value for boolean data type. So, there are only two values possible in boolean data type. You can also write like this put in square, sorry, double quotes then it becomes a string now. Whatever you mention inside this double quotes will become string. So, this is the difference between string and boolean operator. You might be asking whether true will be taken as string or boolean data type. So, now this is boolean. So, if you try to print the value of x and y it will print true and false. So, false also means 0 and true also means 1 or any real value means a real value. So, only the these two values can be accepted by the boolean variables whether any variable sorry, I mean the name of the boolean variables can be anything but it should strictly follow the conventions. It should not start with a number and it should not have any special characters. Okay. Okay, that's how you know. Let's stop with this and go for the next lecture. Hey, guys I welcome you all to lecture number 7. So, in this lecture we are going to see about the if statement and if statements. Okay. So, how it is used put in, you know, in JavaScript and we are going to understand the use of assignment operators or comparison operators also. So, let us write where variable x or where x is equal to 5. Okay. Let us write where y is equal to 5. This is also possible or you can write like this also. Okay. If y x is equal to 5 then y is also equal to 5. Okay. So, let us syntax of if statement is if inside the bracket inside this bracket you have to give you give the condition open a block, close a block. Right. So, if the condition given inside the bracket is true then the block will be executed. Okay. This block will be executed. So, let us write let us take whether x is equal equal x equal equal y which means that it will check this is the you know called equality operator. This will check whether the left hand operand and right hand operand are equal. If these two are equal then let us print document dot write write. This is the function used to print. Let us print. Great. True. Okay. True. Let us print true. Okay. So, how it works you know it will check x is equal to y and this equality operator has two values either true or false. If these two are this condition is true this will return true and this box will be this block will be executed. You can give anything here. Okay. Let us save this code. Go to the browser. Refresh it. It is true. Right. Because x is x actually equals 5. Oh, it is true. So, let us you know let us destroy this condition. Let us make this condition false. y is equal to 10. Any value. Okay. Save this file. Go to the browser. Refresh it. Nothing will be printed because the upload is actually not executed. This condition becomes false here. So, this is the use of statement in JavaScript. This is actually an easy one. And let us use another operator also called you know comparison operator greater than operator. I will check whether x is actually greater than 5. If it is true it will print true. Okay. Save. Go to the browser. Refresh. Nothing will be printed because x is not greater than 5. That's my simple answer. Right. So, let us put x less than 5. Let us save this. Go to the browser. It will print true because 5 is actually less than 10. Right. So, if you use less than operator it will print true. So, this is another way to illustrate the comparison operators. Then you can put less than or equal to and greater than or equal to is actually also possible. Right. So, these are the comparison operators in JavaScript. I am just giving an overview because this course is actually a basic introductory course. Okay. So, this is the way you can use the statement. Let us try to use the Eiffel statement also. Both the statement and the Eiffel statement. Okay. So, let us try to write a code using statement and Eiffel statement. So, let us declare a variable variable x is equal to 5 and another variable y is equal to maybe 15. Okay. If x equals equals y which means that if x is equal to y you have to print document.write document.write both are equal. Okay. Yeah, that is the obvious statement. Right. Both are equal. Else else document.write both are not equal. It is a syntax for else statement. So, else statement can't exist without Eiffel statement. Okay. Then this will not work. Else statement should be placed immediately after the statement. But the else statement is actually optional. It can be neglected if it is not necessary. Let us save this code and go to the browser. Okay. We will print both are not equal because because let us go to the source. Right. Because x and y are not equal. It is only 5 and 150. Let us get the user input for x and y. Let us print sorry. Let us declare variables like this where x, y for x get the user input document.write sorry to print something. Right. It is not the correct way to write the code. window.prompt window.prompt enter number one. Right. Enter a number or number one. What I mean is not actually meaning the number one. Enter first number. Let it be. Let us not make much confusion. Enter first number. So, y equals window.prompt enter second number. Okay. Let us end this with a semicolon. Then save this code. Go to the browser. It will ask the first number. Let us enter the number. Maybe 13. Right. It is all second number. Let us enter the number also. 13 will enter. Let us check whether it is printing both are equal. Okay. Yeah, both are equal. See it works. Okay. Our code works. So, this is how you get the output from the first statement. And this is actually very, very important. The first statement is one of the important in any programming language. Okay. The statement will be important. Then in the next video we are going to see how to use loops in JavaScript. Okay. Thank you. Hey, guys. I welcome you all to lecture number eight. In this lecture we are going to see how to use LCIF statements or otherwise it is called LCIF later in C programming actually. Let us check how to use that. Okay. So, let us remove these. So, variable X is equal to Y. Let us declare those variables. Let us initialize those variables. X is equal to 5 and Y is actually initialized 10. These are the initial values of X and Y. And let us declare another variable also. Right. Let us declare another variable. Is that equals to 5? So, LCIF statement can be written like this. If X is equal to Y you print. If X open the block, you document. Right. You know, print X. Okay. Let us print X. Okay. LCIF, which means that LCIF this statement is not true. Go for the LCIF statement but take a condition there. For the LCIF statement also there is a condition. Okay. That is what it means. If Y equal equal Z you print document. Right. The value of Y. Okay. So, let us close this code. Or you can put any number of LCIF statements. Okay. If LCIF, okay. You can put any number of LCIF statement. If Y not equals to Z let us print document. This is called document. This is called not equal. Okay. And an exclamation mark is equal to sign. Not equal. Okay. Document dot right. Value of Z and put a semicolon post this. Else the last statement should be else. This is optional. Document dot right. Let us try to print. Sorry. Okay. Just a mere statement. Okay. Nothing behind it. Okay. So what it will actually do it will first check X is equal to Y. If it is true it will print X. Otherwise it will go and check the other statement. Else it will take Y equal Z. If this is also true it will print Y and stop executing and complete the LCIF statement. If it is not true then it will go and check the other statement. If it is true it get printed or not true. Finally it will print else statement. Okay. If nothing out of these statements are true it will print else statement. Okay. Let us save this code. This is what we call as LCIF later. Let us save this code go to the browser. Refresh that 5 is printed. Why it is printing 5? Let us check that in our code. Y is equal to 5. Y is equal to 10. It will check 5 equals 10. It is not true condition is actually false so this will not be executed. Then it will check whether Y is equal to 5. 10 is equal to 5 it is also not true though this box will not be executed it will move on to the next block. It will check 10 is not equal to 5. 10 not equal to 5 the condition is actually true then it will print the value of Z. Z is actually 5. So 5 is getting done. So this is how the LCIF later will look like. Thank you. Hey guys this lecture, lecture number 9 actually. We are going to use loops to do our operations. Okay. So we are going to check how to use loop. Okay. What do you mean by loop actually? In programming loop means that particular statement should be executed again and again until the condition gets false. That is what it actually repeats the iteration. So it can execute a block of code in number of times. Now the number of times can be mentioned by the user. The condition also can be mentioned by the user. The statement also as well. Okay. So let us if the condition is true it will execute it as my number of times till the condition gets false. That is actually called as a loop. Okay. So looping right. Looping again and again. That is what it means actually. So let us check, let us first try to understand the for loop. So for loop has three arguments. Okay. The first argument should be your initial value i equals 0 and semicolon this can be any variable let us declare that variable. You should declare that variable here or you can also declare that inside the for loop also. Okay. Variable i equals 0 which means sorry you may be knowing it right. If you are actually good in programming you may be knowing it. That means a variable i will be declared and it has initialized the value with 0. It has been initialized the value of 0. Then let us put a condition i less than or equals 10. Okay. Okay. So the second statement should be condition in for loop. This for loop is actually called as classical for loop in JavaScript. Okay. So first statement should be initialization. Second statement should be condition. Okay. It will check whether i is less than 10 or not. Then you have to increment the value of i. Or else it will become an infinite loop. Okay. The top search result of i. Okay. So after incrementing, so this is our for loop. This is how you write the for loop. Okay. So inside the for loop you can write the statement. Okay. Let us try to print the value of i itself. One dot write i. Okay. Let us close the for loop. Save this file. Let us go to save and let us go to the browser and check this. Okay. Let us open this file here. Hit print 0, 1, 2, 3, 4, 5. What it what it means is first let us check this. Okay. First i will be declared 0. i will be initialized to value 0. Okay. Then it will the condition will be check whether it is whether 0 is less than 10. Less than or equals 10. Okay. If the condition is true then i will be printed. Okay. So it prints 0 here. Okay. The next statement will be i is initialized to 0 and 0 is less than or i is okay. I am sorry. The next statement would be incremented. So i plus plus becomes 1. We have already seen that 0 plus 1 becomes 1. So again it will check the condition whether 1 is less than or equals 10. If it is true it will print i. So now the i value is actually 1. Okay. So 1 will be printed. Clear. So let us go and check another. Again the i will be incremented. i becomes 2 now. So 2 less than or equal to 10. The condition is true. So it gets printed. 2 gets printed. So again i will be incremented. i will be 3. So 3 less than or equal to 10 is true. So 3 will be printed. Until 10. Okay. Until let us say i equals 10 after so many incremented operations. So if it is 10 less than or equal to 10. Conditions also true. So i will be printed. Then i will be incremented. i becomes 11. Then we will check 11 less than or equal to 10. Conditions are false. It will come out of the form. Okay. So up to 10 the numbers will be printed. So we have written a code to print the numbers from 0 to 10 in JavaScript. So using for loop. So this is how you use for loop in JavaScript. Okay. So this statement is actually optional. All the 3 arguments in this for loop is actually optional. Okay. We can remove this. We can leave it as blank and you can declare in the first statement. I have i is equal to 0. Save this. Go to the and this will be executed. Okay. It works one of the same as we have done before. Okay. So this is how you write for loop. Let us remove this increment operator and check what happens. Okay. This will be fun. Right. Let us have the condition. We have initialization. Not a problem. But we have removed the increment increment or decrement operator. Can use decrement also. It is also possible. Let us go to the browser. We can see the the loading option. The loading is actually seen here. Just getting continuously loaded. Which means that it could not come out of the loop. The web page will be loading version loading. Okay. It could not come out of the loop. Which means that it leads to an infinite loop. Okay. It leads to an infinite loop. So you have to even increment or decrement statement here. It is i equals i plus 1. This is also possible. Or I can give i equals i plus 3. Any value you can give. But it should increment our counter. This is called counter. Increment our decrement. Anything. Increment or decrement our counter. Okay. Let us go to the browser. The web page is not responding. I think it has hanged. Right. Let us get back to it. Don't use infinite pages. Then it will become a problem to your web page. So 0 3 6 9. Because i is incremented by value 3 times. So it will increment by 3. Right. So 0 3 6 9. Multiple of 3 gets printed. So let's go to the source. So this is also optional. Sorry not optional. You can leave this and give it inside. Not a problem. Okay. Like inside the loop. Let us stay i plus 10. Let us save this. Go to the browser. Then refresh. Yeah. It will be executed. Same that we have seen before. Right. So this is what I mean by a for loop. So this is actually important in the script. This is called classical for loop. There is another for loop also. That you can see through the net. That is actually outdated. Okay. So this is how you write a for loop. Clear. Right. So let us now try to know about the breaker. Okay. Let us see that in the next video. Thank you. Hey guys. I welcome you all to the next number 10. In this lecture we are going to see about why it looks actually very similar to for loop except the fact that it has only one parameter or one argument whatever you can say. It is actually the condition. It has only the condition. So let us write the code here. Let us say variable variable i where i is equal to zero. It is initialized with a value called zero. So let us write a while loop i you know let us say less than equal to 50. Okay. 50. Then it depends on the document dot i. I will be printed but i should be incremented. Right. Then only it will be incremented. Otherwise it can go into an infinite loop. It will cause harm to harm to harm. So i plus plus save this. Let us open the file. Yeah. Yeah. It will start printing from zero up to fifty. But what is that I couldn't read any numbers or we have to use one statement called break statement then only the break to prove it I'll show the syntax add plus in say double column you put br right this is syntax for the break statement save it go to the browser refresh yeah this break statement is actually used in html to break the line sentences okay so if you break the you know the statement it will be like this for every iteration break will be executed then all will be a printed like one by one okay so this understand that this is different from the break statement which is used in JavaScript this is actually in html there is another break statement also that is actually different if you give that okay let me explain it in a separate lecture okay break and continue statement is different this lecture is all about while loop so this is how you write while loop okay yeah this is the basic concepts about while loop and understand that there is one more key I have the whole understand here the while loop will execute until the condition gets falls if the condition gets falls the while will come out of execution okay so let us see one more loop is do while loop in the next lecture thank you guys I welcome you all to lecture number 11 in this lecture we are going to see about do while okay so what is the difference between do while loop and while loop why we need a loop like do while so the syntax of do while is this your first write a do statement then why a condition should be given with a semicolon remember this semicolon this is not in while loop if you give this semicolon while loop then nothing will be executed okay it it iterates by in the condition itself nothing will be executed not throw in a error but the do while loop this semicolon should be given move that first first do then while what it means is try to print the dot right okay let us try to print I value okay I value plus give give a break otherwise it will confuse me or confuse us sorry okay let us give the statement here also the condition here inside the while loop I should be less than equals one and let's say one okay let's see what happens or I less than one given okay let's see what happens so I have declared a variable I with value one and I'm trying to print a value of I with so the break statement is not necessary one and I'm checking the condition if one is less than one so let us try to print the value yeah one is getting printed here please remember that one's getting printed what do you mean is one is actually initialized to I so first do do block will be executed which means that first it will print the value of I then only it will check the condition if you do this same procedure in while loop it will and nothing will be printed okay so let us check the while loop also whether it will get printed or not let's close this let us cut so while I less than I'll give the same condition why I less than one document dot write I save this go to the browser yeah nothing will be printed okay so it prints nothing because the condition is actually false but if you do the same in the do while statement first it will it will print the it will execute the block or execute the statement then only the condition will be checked or in other words I can say it will print an extra statement when compared to the while loop okay it will print it while you print the end statements it will print n plus one statement or it will execute and what is the difference between do while and while in while the condition will be checked first then the block will be executed here in do while the block will be executed first then only the condition will be checked that is the difference between do while and while loop you have a usage of do while in your I know some standard programs whether I can I can show you in the description okay thank you hello guys welcome you all to this lecture this lecture is all about alert function prompt function and okay we have already seen about prompt function in the previous lecture it will prompt the user and it will get an input something you said right let us see about alert function what will be okay let us write alert very simple let us write alert uh this is javascript okay any statement we can put here any string semicolon save this go to the browser refresh it will give an alert box so in this side this side says this is javascript whatever you enter here will be displayed in the alert box in the source okay so let us save this so the alert box will say hi okay so this is one uh an important future of javascript an alert function we have one more function called confirm okay confirm do you really need this do you really need this okay let us understand the difference between alert and confirm okay let us save this go to the yeah it will say uh it will ask whether do you really need uh can press whether okay or cancel okay so let us uh you can understand uh the difference between confirm and alert let us see it using a program let us write variable x x equals confirm are you sure want to close this page right this is the real usage of this confirm function it will confirm your uh intention okay so uh what i mean is i have written a statement confirm are you sure want to close this page uh variable uh x okay so what i what i mean is this confirm is a function it it it it returns some values right it it returns some values and that value you can be stored in a left hand operand then only you can mention this left hand operand what i mean is if the function uh returns some values you can store that in a left hand operand okay uh the function may or may not return some values confirm return some value that's why i'm storing it some uh variable and it is a uh boolean it is almost similar to boolean it returns only true two values true and uh false okay so if you press okay it will return true that will be stored in x so x is a boolean variable uh if you press cancel it will be taken as false and that will be stored in x okay let us check if x equals equals true true x equals true uh print okay let us put an alert box okay alert thanks okay else let us print document right kindly continue kindly let us print kindly continue so this is how we use uh usage of confirm option will be uh if you ask whether uh the user wants to close the page really then that will be stored in x the result will be stored in x the result of this confirm function without the you know the output of this confirm function let's save this let's go to the browser and check so it it it asks me are you sure want to close this page i press okay then it will print thanks right so because okay is uh because uh okay is actually true uh if you press okay it is taken as true so uh true will be stored in the x so it will compare uh x x to true x is actually true so true will be compared to true the condition gets uh true so this will be printed thanks will uh sorry this will be alerted the thanks will be alerted uh let us check the uh contrary condition also or you sure want to press cancel we press cancel kindly continue that will be can you solid here also the user depends upon the user okay the user the user depends upon the uh um one who writes this code okay so how have you stopped this lecture thank you all thanks for your uh continued support uh i think these are the fundamentals of java script which i wanted to teach so maybe in further courses we'll uh see in deep about the functions arrays and all but these are the fundamentals this will give you an idea of javascript and it will uh make sure that uh it is easy to learn okay javascript is very easy to learn and these uh video lectures might have proved okay so thank you thanks for our continued support