@ -61,12 +61,12 @@ A boolean data type represents one of the two values:_true_ or _false_. Boolean
**Example: Boolean Values**
```js
let isLightOn = true
let isRaining = false
let isHungry = false
let isMarried = true
let truValue = 4 > 3 // true
let falseValue = 4 <3//false
let isLightOn = true;
let isRaining = false;
let isHungry = false;
let isMarried = true;
let truValue = 4 > 3; // true
let falseValue = 4 <3;//false
```
We agreed that boolean values are either true or false.
@ -94,15 +94,15 @@ It is good to remember those truthy values and falsy values. In later section, w
If we declare a variable and if we do not assign a value, the value will be undefined. In addition to this, if a function is not returning the value, it will be undefined.
```js
let firstName
console.log(firstName) //not defined, because it is not assigned to a value yet
let firstName;
console.log(firstName); //not defined, because it is not assigned to a value yet
```
## Null
```js
let empty = null
console.log(empty) // -> null , means no value
let empty = null;
console.log(empty); // -> null , means no value
```
## Operators
@ -112,13 +112,13 @@ console.log(empty) // -> null , means no value
An equal sign in JavaScript is an assignment operator. It uses to assign a variable.
@ -260,17 +257,17 @@ In JavaScript we use the increment operator to increase a value stored in a vari
1. Pre-increment
```js
let count = 0
console.log(++count) // 1
console.log(count) // 1
let count = 0;
console.log(++count); // 1
console.log(count); // 1
```
1. Post-increment
```js
let count = 0
console.log(count++) // 0
console.log(count) // 1
let count = 0;
console.log(count++); // 0
console.log(count); // 1
```
We use most of the time post-increment. At least you should remember how to use post-increment operator.
@ -282,17 +279,17 @@ In JavaScript we use the decrement operator to decrease a value stored in a vari
1. Pre-decrement
```js
let count = 0
console.log(--count) // -1
console.log(count) // -1
let count = 0;
console.log(--count); // -1
console.log(count); // -1
```
2. Post-decrement
```js
let count = 0
console.log(count--) // 0
console.log(count) // -1
let count = 0;
console.log(count--); // 0
console.log(count); // -1
```
### Ternary Operators
@ -301,15 +298,15 @@ Ternary operator allows to write a condition.
Another way to write conditionals is using ternary operators. Look at the following examples:
```js
let isRaining = true
let isRaining = true;
isRaining
? console.log('You need a rain coat.')
: console.log('No need for a rain coat.')
isRaining = false
: console.log('No need for a rain coat.');
isRaining = false;
isRaining
? console.log('You need a rain coat.')
: console.log('No need for a rain coat.')
: console.log('No need for a rain coat.');
```
```sh
@ -318,15 +315,15 @@ No need for a rain coat.
```
```js
let number = 5
let number = 5;
number > 0
? console.log(`${number} is a positive number`)
: console.log(`${number} is a negative number`)
number = -5
: console.log(`${number} is a negative number`);
number = -5;
number > 0
? console.log(`${number} is a positive number`)
: console.log(`${number} is a negative number`)
: console.log(`${number} is a negative number`);
```
```sh
@ -345,11 +342,11 @@ I would like to recommend you to read about operator precedence from this [link]
As you have seen at very beginning alert() method displays an alert box with a specified message and an OK button. It is a builtin method and it takes on argument.
```js
alert(message)
alert(message);
```
```js
alert('Welcome to 30DaysOfJavaScript')
alert('Welcome to 30DaysOfJavaScript');
```
Do not use too much alert because it is destructing and annoying, use it just to test.
@ -359,12 +356,12 @@ Do not use too much alert because it is destructing and annoying, use it just to
The window prompt methods display a prompt box with an input on your browser to take input values and the input data can be stored in a variable. The prompt() method takes two arguments. The second argument is optional.
```js
prompt('required text', 'optional text')
prompt('required text', 'optional text');
```
```js
let number = prompt('Enter number', 'number goes here')
console.log(number)
let number = prompt('Enter number', 'number goes here');
console.log(number);
```
### Window confirm() method
@ -374,8 +371,8 @@ A confirm box is often used to ask permission from a user to execute something.
Clicking the OK yields true value, whereas clicking the Cancel button yields false value.
```js
const agree = confirm('Are you sure you like to delete? ')
console.log(agree) // result will be true or false based on what you click on the dialog box
const agree = confirm('Are you sure you like to delete? ');
console.log(agree); // result will be true or false based on what you click on the dialog box
```
These are not all the window methods we will have a separate section to go deep into window methods.
@ -385,15 +382,15 @@ These are not all the window methods we will have a separate section to go deep
Time is an important thing. We like to know the time a certain activity or event. In JavaScript current time and date is created using JavaScript Date Object. The object we create using Date object provides many methods to work with date and time.The methods we use to get date and time information from a date object values are started with a word _get_ because it provide the information.
🌕 You have boundless energy. You have just completed day 3 challenges and you are three steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle.
🌕 You have boundless energy. You have just completed day 3 challenges and you are three steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle.
1. Write three JavaScript statement which provide truthy value.
2. Write three JavaScript statement which provide falsy value.
5. Figure out the result of the following comparison expression first without using console.log(). After you decide the result confirm it using console.log()
[<< Dia 4](../Dia_04_Condicionais.md) | [Dia 6 >>](../Dia_06_Loops/Dia_06_Loops.md)


- [📔 Dia 5](#-dia-5)
- [Arrays](#arrays)
@ -169,7 +169,7 @@ console.log(words);
Acessamos cada elemento em um array usando seu índice. O índice de um array começa do 0. A imagem abaixo mostra claramente o índice de cada elemento no array.