You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Console math and boolean exercises implements (#203)
* Began writing set-interval document
* Added code example for setInterval
* Completed example on setInterval paramters
* Added clear interval section
* Revised set-interval document
* Created set-timeout document
* Added clear timeout secion
* Added info on Inheritance document and class chapter
* Added chapter and page number to setTimeout and SetInterval
* Added math in console exercise
* Added boolean testing in console exercises
---------
Co-authored-by: Suman Kunwar <[email protected]>
Copy file name to clipboardExpand all lines: en/exercises/console.md
+35-2Lines changed: 35 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,13 +14,46 @@ let age = 30;
14
14
console.log(age);
15
15
```
16
16
17
+
## Math with console
18
+
You can also write math equation in `console` in order to know the answer to an expression.
19
+
20
+
### Example:
21
+
```js
22
+
console.log("What's the age a decade later?");
23
+
let age =30;
24
+
console.log(age +10);
25
+
//returns 40 in the console
26
+
```
27
+
28
+
## Booleans in console
29
+
Another useful way developers use console is to check wether something is true or false. For instance in the example below you can check wether the age of a person being equal to 45 is true or false.
30
+
31
+
### Example:
32
+
```js
33
+
console.log("Are they 50 years old?");
34
+
let age =30;
35
+
console.log(age ===50);
36
+
//result: false
37
+
```
38
+
17
39
### 📝 Tasks:
18
40
19
-
*[ ] Write a program to print `Hello World` on the console. Feel free to try other things as well!
20
-
*[ ]Write a program to print variables to the `console`. 
41
+
* Write a program to print `Hello World` on the console. Feel free to try other things as well!
42
+
* Write a program to print variables to the `console`. 
21
43
1. Declare a variable `animal` and assign the dragon value to it.
22
44
2. Print the `animal` variable to the `console`.
45
+
* Write a program to print the number `45` with a math expression of your choice. (Bonus if one of the numbers is a variable!)
46
+
47
+
* Write a program in the console that checks if the amounts of eggs is more than `12`.
48
+
1. Declare a variable `eggs` and assign a number of your choice to it
49
+
2. Call the `eggs` variable in the `console` and use the correct operator to see if the number assigned to `eggs` is greater that 12
50
+
* If the number of eggs is greater, it should print `true`, if not then it should print `false`
51
+
52
+
53
+
54
+
23
55
24
56
### 💡 Hints:
25
57
26
58
* Visit the [variable](../basics/variables.md) chapter to understand more about variables.
59
+
* Visit the [operators](https://javascript.sumankunwar.com.np/en/numbers/operators.html) page to know the possible operators you can use.
0 commit comments