pull/59/head
Asabeneh 5 years ago
parent ac2ff0daf8
commit a47f48f23e

@ -65,7 +65,7 @@ let isRaining = false
let isHungry = false let isHungry = false
let isMarried = true let isMarried = true
let truValue = 4 > 3 // true let truValue = 4 > 3 // true
let falseValue = 3 < 4 // false let falseValue = 4 < 3 // false
``` ```
We agreed that boolean values are either true or false. We agreed that boolean values are either true or false.

@ -13,7 +13,7 @@
</sub> </sub>
</div> </div>
[<< Day 10](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_Set_and_Map.md) | [Day 12>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_regular_expressions.md) [<< Day 10](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/10_Day/10_day_Set_and_Map.md) | [Day 12>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_regular_expressions.md)
![Day 11](../images/banners/day_1_11.png) ![Day 11](../images/banners/day_1_11.png)
@ -691,4 +691,4 @@ const users = [
``` ```
🎉 CONGRATULATIONS ! 🎉 🎉 CONGRATULATIONS ! 🎉
[<< Day 10](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_Set_and_Map.md) | [Day 12>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_regular_expressions.md) [<< Day 10](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/10_Day/10_day_Set_and_Map.md) | [Day 12>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_regular_expressions.md)

@ -11,11 +11,13 @@
<a href="https://www.linkedin.com/in/asabeneh/" target="_blank">Asabeneh Yetayeh</a><br> <a href="https://www.linkedin.com/in/asabeneh/" target="_blank">Asabeneh Yetayeh</a><br>
<small> January, 2020</small> <small> January, 2020</small>
</sub> </sub>
</div> </div>
[<< Day 12](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_regular_expressions.md) | [Day 14>>](#) [<< Day 12](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_regular_expressions.md) | [Day 14>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_error_handling.md)
![Thirty Days Of JavaScript](../images/banners/day_1_13.png) ![Thirty Days Of JavaScript](../images/banners/day_1_13.png)
- [Day 13](#day-13) - [Day 13](#day-13)
- [Console Object Methods](#console-object-methods) - [Console Object Methods](#console-object-methods)
- [console.log()](#consolelog) - [console.log()](#consolelog)
@ -73,7 +75,14 @@ We can style logging message using css. Copy the following code and paste it on
```js ```js
console.log('%c30 Days Of JavaScript', 'color:green') // log output is green console.log('%c30 Days Of JavaScript', 'color:green') // log output is green
console.log('%c30 Days%c %cOf%c %cJavaScript%c','color:green','', 'color:red', '', 'color:yellow') // log output green red and yellow text console.log(
'%c30 Days%c %cOf%c %cJavaScript%c',
'color:green',
'',
'color:red',
'',
'color:yellow'
) // log output green red and yellow text
``` ```
### console.warn() ### console.warn()
@ -82,7 +91,9 @@ We use console.warn() to give warning on browser. For instance to inform or war
```js ```js
console.warn('This is a warning') console.warn('This is a warning')
console.warn('You are using React. Do not touch the DOM. Virtual DOM will take care of handling the DOM!') console.warn(
'You are using React. Do not touch the DOM. Virtual DOM will take care of handling the DOM!'
)
console.warn('Warning is different from error') console.warn('Warning is different from error')
``` ```
@ -122,7 +133,11 @@ console.table(user)
Check the rest of the examples by copying and paste on the browser console. Check the rest of the examples by copying and paste on the browser console.
```js ```js
const countries = [['Finland', 'Helsinki'], ['Sweden', 'Stockholm'], ['Norway', 'Oslo']] const countries = [
['Finland', 'Helsinki'],
['Sweden', 'Stockholm'],
['Norway', 'Oslo']
]
console.table(countries) console.table(countries)
``` ```
@ -161,15 +176,19 @@ console.table(users)
``` ```
### console.time() ### console.time()
Starts a timer you can use to track how long an operation takes. You give each timer a unique name, and may have up to 10,000 timers running on a given page. When you call console.timeEnd() with the same name, the browser will output the time, in milliseconds, that elapsed since the timer was started. Starts a timer you can use to track how long an operation takes. You give each timer a unique name, and may have up to 10,000 timers running on a given page. When you call console.timeEnd() with the same name, the browser will output the time, in milliseconds, that elapsed since the timer was started.
```js ```js
const countries = [['Finland', 'Helsinki'], ['Sweden', 'Stockholm'], ['Norway', 'Oslo']] const countries = [
['Finland', 'Helsinki'],
['Sweden', 'Stockholm'],
['Norway', 'Oslo']
]
console.time('Regular for loop') console.time('Regular for loop')
for (let i = 0; i < countries.length; i++) { for (let i = 0; i < countries.length; i++) {
console.log(countries[i][0], countries[i][1]) console.log(countries[i][0], countries[i][1])
} }
console.timeEnd('Regular for loop') console.timeEnd('Regular for loop')
@ -222,8 +241,8 @@ console.assert(4 > 3, '4 is greater than 3') // no result
console.assert(3 > 4, '3 is not greater than 4') // Assertion failed: 3 is not greater than 4 console.assert(3 > 4, '3 is not greater than 4') // Assertion failed: 3 is not greater than 4
for (let i = 0; i <= 10; i += 1) { for (let i = 0; i <= 10; i += 1) {
let errorMessage = `${i} is not even`; let errorMessage = `${i} is not even`
console.log('the # is ' + i); console.log('the # is ' + i)
console.assert(i % 2 === 0, { number: i, errorMessage: errorMessage }) console.assert(i % 2 === 0, { number: i, errorMessage: errorMessage })
} }
``` ```
@ -234,7 +253,11 @@ The console.group() can help to group different log groups. Copy the following c
```js ```js
const names = ['Asabeneh', 'Brook', 'David', 'John'] const names = ['Asabeneh', 'Brook', 'David', 'John']
const countries = [['Finland', 'Helsinki'], ['Sweden', 'Stockholm'], ['Norway', 'Oslo']] const countries = [
['Finland', 'Helsinki'],
['Sweden', 'Stockholm'],
['Norway', 'Oslo']
]
const user = { const user = {
name: 'Asabeneh', name: 'Asabeneh',
title: 'Programmer', title: 'Programmer',
@ -285,7 +308,6 @@ console.group('Users')
console.log(user) console.log(user)
console.log(users) console.log(users)
console.groupEnd() console.groupEnd()
``` ```
### console.count() ### console.count()
@ -323,7 +345,7 @@ The console.clear() cleans the browser console.
### Exercises:Level 2 ### Exercises:Level 2
1. 10 > 2 * 10 use console.assert() 1. 10 > 2 \* 10 use console.assert()
2. Write a warning message using console.warn() 2. Write a warning message using console.warn()
3. Write an error message using console.error() 3. Write an error message using console.error()
@ -331,7 +353,6 @@ The console.clear() cleans the browser console.
1. Check the speed difference among the following loops: while, for, for of, forEach 1. Check the speed difference among the following loops: while, for, for of, forEach
🎉 CONGRATULATIONS ! 🎉 🎉 CONGRATULATIONS ! 🎉
[<< Day 12](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_regular_expressions.md) | [Day 14>>](#) [<< Day 12](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_regular_expressions.md) | [Day 14>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_error_handling.md)

Loading…
Cancel
Save