|
5 | 5 | They will help us up to guide you through the javaScript introduction journey.
|
6 | 6 | There is a multi-line comments, like this one and also you can leave a single line comment
|
7 | 7 | right in your code, example below. If you need to write some notes use comments starting with '//'
|
| 8 | + To comment out - means comment your lines of code, so computer skip them. |
8 | 9 | */
|
9 | 10 |
|
10 | 11 | //I'm your one-line comment
|
|
14 | 15 | There is few ways you can do it and we will look into few of them:
|
15 | 16 | - console.log('Hello World!'); - this line of code will print 'Hello World!' to the browser's console.
|
16 | 17 | P.S: To see browser's console you can do right click in the window of you browser(Chrome, Firefox etc)
|
17 |
| - and select 'Inspect' or 'Inspect element' after that a console will appear on the bottom of the page. |
| 18 | + and select 'Inspect' or 'Inspect element' after that a console will appear on the bottom/right side of the page. |
18 | 19 | - alert('Hello girls!'); - this line of code will pop-up a small window in your browser with text 'Hello girls!' in it,
|
19 | 20 | but you need to refresh opened page first.
|
20 | 21 | */
|
|
26 | 27 |
|
27 | 28 |
|
28 | 29 |
|
29 |
| -//TODO: After alert works for you, comment it out and refresh the page - it should not pop-up anymore. |
| 30 | +//TODO: After alert works for you, comment it out(put '//' on the line where your code is and save changes) after refresh the page - |
| 31 | +// it should not pop-up anymore. |
30 | 32 |
|
31 | 33 | //TODO: What you say about trying console.log your message to browser? Send any message you like.
|
32 | 34 |
|
|
48 | 50 | Boolean - it represents logical values - True or False
|
49 | 51 | */
|
50 | 52 |
|
51 |
| -//TODO: Now create two empty variable named numberOne and numberTwo |
| 53 | +//TODO: Now create two empty variables named numberOne and numberTwo |
52 | 54 |
|
53 | 55 |
|
54 | 56 |
|
|
67 | 69 |
|
68 | 70 |
|
69 | 71 |
|
70 |
| -//TODO: Don't forget to comment alerts if you don't want them to pop-up every time |
| 72 | +//TODO: Don't forget to comment out alerts if you don't want them to pop-up every time |
71 | 73 |
|
72 | 74 |
|
73 | 75 | /* Arithmetic operators
|
|
96 | 98 | To call the function we do so:
|
97 | 99 | functionName(10);
|
98 | 100 | Now we will call our function with argument that is 10. And our function will return us 20. To see what our function
|
99 |
| - returns us we can console.log it, for example. |
| 101 | + returns us we can console.log it, for example: |
| 102 | + console.log(functionName(10)); |
100 | 103 | */
|
101 | 104 |
|
102 | 105 | //TODO: It's your turn to create a function.
|
103 |
| -//Step 1 - Name it 'add' and pass in two argumnets (num1 and num2). |
| 106 | +//Step 1 - Name it 'add' and pass in two argumnets (num1 and num2) - to pass multiple arguments into function we seperate them with coma. |
104 | 107 | //Step 2 - This function should return us a sum of num1 and num2.
|
105 |
| -//Step 3 - Call the function with numbers 2 and 3. To see result you can alert it or console.log it - to be sure that it works right. |
| 108 | +//Step 3 - Call the function passing numbers 2 and 3 as arguments. To see result you can alert it or console.log it - to be sure that it works right. |
106 | 109 |
|
107 | 110 |
|
108 | 111 |
|
|
122 | 125 |
|
123 | 126 | /*If-else statements
|
124 | 127 | What if we want our program to make a decision which function it should run? In this case we can use conditions.
|
125 |
| - If spider is big, action should be - run and save your life, but if it is tiny you can simply walk away. |
| 128 | + If you have TV you can watch it in the evening, if not - you might do something else. |
126 | 129 | Same with code, you can give 'if' condition to machine to make a decision what part of code to run.
|
127 | 130 | Structure:
|
128 | 131 | if(condition){
|
|
0 commit comments