Skip to content

Commit 6864cd7

Browse files
Lensco825sumn2u
andauthored
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]>
1 parent cbed754 commit 6864cd7

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

en/exercises/console.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,46 @@ let age = 30;
1414
console.log(age);
1515
```
1616

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+
1739
### 📝 Tasks:
1840

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`.&#x20;
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`.&#x20;
2143
1. Declare a variable `animal` and assign the dragon value to it.
2244
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+
2355

2456
### 💡 Hints:
2557

2658
* 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

Comments
 (0)