1 00:00:00,630 --> 00:00:03,300 Hello and welcome to this video. 2 00:00:03,570 --> 00:00:13,200 I'll be explaining how to use comments in your program called what are called Comments good comments 3 00:00:13,270 --> 00:00:26,140 are busy clean text that you write inside your code to explain certain aspects of your code comments 4 00:00:26,150 --> 00:00:35,630 you're right in your code and not really useful to the computer itself but they are useful to you as 5 00:00:35,670 --> 00:00:43,830 the programmer or developer and to others who may have to look at your code add some other time. 6 00:00:43,850 --> 00:00:50,450 Sometimes you may write some code and maybe three four weeks or even a few months down the line. 7 00:00:50,460 --> 00:00:57,780 Come back to look at the code some parts of it may not make sense so if you leave comments in your code 8 00:00:57,780 --> 00:01:06,210 to explain why certain aspects of your code does what he does then he may jog your memory as to why 9 00:01:06,210 --> 00:01:07,930 you wrote that quote. 10 00:01:07,950 --> 00:01:12,720 It also helps others who may have to look at your code at some other time. 11 00:01:12,720 --> 00:01:22,560 So apart from writing programs that work correctly is also used for and that programs make sense when 12 00:01:22,580 --> 00:01:25,040 someone examines your code. 13 00:01:25,350 --> 00:01:30,270 You can also use chord comments for testing purposes. 14 00:01:30,450 --> 00:01:38,700 There may be some aspects of your code that you may not want to be executed and you can implement that 15 00:01:38,700 --> 00:01:41,510 by using comments. 16 00:01:41,520 --> 00:01:48,330 There are two main types of comments used in the javascript programming language. 17 00:01:48,390 --> 00:01:54,690 Every programming languages have their own way of inserting comments in javascript. 18 00:01:54,690 --> 00:02:02,940 The way you insert comments is either on a single line of code or you can instead comments on multiple 19 00:02:02,940 --> 00:02:10,770 lines of court so you have a single line comment which is represented by day to false lashes or multiple 20 00:02:10,770 --> 00:02:16,710 line comments where you start the first line with a four slash and an asterisks and then everything 21 00:02:16,740 --> 00:02:25,000 in between the up in unclosing asterisks will be provided us comments are when the code is executed 22 00:02:25,000 --> 00:02:30,590 and the computer completely ignores the comments. 23 00:02:30,650 --> 00:02:42,090 Comments can explain why and also what certain aspects of your code is doing. 24 00:02:42,290 --> 00:02:52,350 Is it has a good programmer to focus more on why a certain aspect of the code not what but you can also 25 00:02:52,350 --> 00:02:59,700 use it to explain why and also what my developer console. 26 00:02:59,700 --> 00:03:08,840 I have caught some examples of comments and it doesn't really matter where you write your javascript. 27 00:03:08,840 --> 00:03:13,630 I have I am the console or on a text editor. 28 00:03:13,970 --> 00:03:18,480 Their comments will behave the same way so you can see here. 29 00:03:18,880 --> 00:03:24,530 It is a variable I have declared given it a name given it. 30 00:03:24,690 --> 00:03:30,660 That is a name and a variable name and I'm using this assignment operate on time assigning the value 31 00:03:30,660 --> 00:03:35,340 of Rick so you can see here is the end of the statement. 32 00:03:35,610 --> 00:03:39,660 And here you can see quote a single line comment. 33 00:03:40,050 --> 00:03:45,520 So the comment basically says this stores the name stores name. 34 00:03:45,850 --> 00:03:53,160 Okay so your comments should be meaningful to yourself and also to others so you can have a single line 35 00:03:53,160 --> 00:03:56,410 comment at this side like up on here. 36 00:03:56,610 --> 00:04:03,430 After tar me state meant us end it the computer when B could execute it all. 37 00:04:03,440 --> 00:04:04,700 To run this line. 38 00:04:04,740 --> 00:04:10,440 Ignore the comment on this line where you got just the comment here. 39 00:04:10,440 --> 00:04:16,140 If the computer can't execute this block of code it will completely ignore the line. 40 00:04:16,140 --> 00:04:19,990 This line here so we can see how this all turned green. 41 00:04:20,100 --> 00:04:22,350 So that means this line will be ignored. 42 00:04:22,350 --> 00:04:26,610 You can see this doesn't turn green because the comments started from here. 43 00:04:26,910 --> 00:04:33,730 So there are two ways you can put the comment either on the side of the code or just before you can 44 00:04:33,730 --> 00:04:34,110 see here. 45 00:04:34,110 --> 00:04:37,130 This is a complete cut so no comment there here. 46 00:04:37,140 --> 00:04:39,120 Well a multiple line comment. 47 00:04:39,120 --> 00:04:45,840 So the comment spans two lines so you can have multiple line comments to span several lines so this 48 00:04:45,840 --> 00:04:47,800 is the opening and this is the closing. 49 00:04:47,950 --> 00:04:52,380 If you have been multiple line comment very important to close them properly. 50 00:04:52,390 --> 00:04:56,970 The way I have done that so you can see here this block of cordice or turn green. 51 00:04:57,210 --> 00:04:59,430 It'll be ignored in the computer. 52 00:05:00,130 --> 00:05:02,290 Ron's or execute the program. 53 00:05:02,550 --> 00:05:03,980 So this it's okay. 54 00:05:03,990 --> 00:05:05,510 And there's no comment here. 55 00:05:05,610 --> 00:05:11,690 This bizarre clip here this comment describes what this function does. 56 00:05:11,900 --> 00:05:19,620 All writes of a process and to see the functionless execute as saying hellowallet I just typical K to 57 00:05:19,650 --> 00:05:20,550 exit. 58 00:05:20,550 --> 00:05:29,280 So that is basically how comments work in javascript or programming languages have their own way of 59 00:05:29,520 --> 00:05:31,310 implementing comments. 60 00:05:31,360 --> 00:05:34,170 But this is how javascript does it. 61 00:05:34,170 --> 00:05:35,460 Thanks for watching. 62 00:05:35,460 --> 00:05:36,370 Bye for now.