| 24 | [Mini Projekt: Układ Słoneczny](./24_Day_Project_solar_system/24_day_project_solar_system.md) |
| 25 | [Mini Projekt: Wizualizacja danych krajów świata 1](./25_Day_World_countries_data_visualization_1/25_day_world_countries_data_visualization_1.md) |
| 26 | [Mini Projekt: Wizualizacja danych krajów świata 2](./26_Day_World_countries_data_visualization_2/26_day_world_countries_data_visualization_2.md) |
- [Introduction to Data types](#introduction-to-data-types)
- [Numbers](#numbers)
- [Strings](#strings)
- [Booleans](#booleans)
- [Undefined](#undefined)
- [Null](#null)
- [Checking Data Types](#checking-data-types)
- [Comments Again](#comments-again)
- [Variables](#variables)
- [💻 Day 1: Exercises](#-day-1-exercises)
# 📔 Day 1
@ -203,7 +198,7 @@ Ctl+Shift+I
To write our first JavaScript code, we used a built-in function **console.log()**. We passed an argument as input data, and the function displays the output. We passed `'Hello, World'` as input data or argument in the console.log() function.
```js
console.log('Hello, World!')
console.log("Hello, World!");
```
##### Console.log with Multiple Arguments
@ -213,9 +208,9 @@ The **`console.log()`** function can take multiple parameters separated by comma
As you can see from the snippet code above, _`console.log()`_ can take multiple arguments.
@ -229,8 +224,8 @@ We can add comments to our code. Comments are very important to make code more r
**Example: Single Line Comment**
```js
// This is the first comment
// This is the second comment
// This is the first comment
// This is the second comment
// I am a single line comment
```
@ -253,17 +248,17 @@ Programming languages are similar to human languages. English or many other lang
I made a deliberate mistake. As a result, the console raises syntax errors. Actually, the syntax is very informative. It informs what type of mistake was made. By reading the error feedback guideline, we can correct the syntax and fix the problem. The process of identifying and removing errors from a program is called debugging. Let us fix the errors:
```js
console.log('Hello, World!')
console.log('Hello, World!')
console.log("Hello, World!");
console.log("Hello, World!");
```
So far, we saw how to display text using the _`console.log()`_. If we are printing text or string using _`console.log()`_, the text has to be inside the single quotes, double quotes, or a backtick.
**Example:**
```js
console.log('Hello, World!')
console.log("Hello, World!")
console.log(`Hello, World!`)
console.log("Hello, World!");
console.log("Hello, World!");
console.log(`Hello, World!`);
```
#### Arithmetics
@ -275,12 +270,12 @@ It is possible to write JavaScript code on Google Chrome console can directly wi
@ -353,7 +348,7 @@ First, let us write on the head part of the page.
<head>
<title>30DaysOfScript:Internal Script</title>
<script>
console.log('Welcome to 30DaysOfJavaScript')
console.log("Welcome to 30DaysOfJavaScript");
</script>
</head>
<body></body>
@ -371,7 +366,7 @@ This is how we write an internal script most of the time. Writing the JavaScript
<body>
<buttononclick="alert('Welcome to 30DaysOfJavaScript!');">Click Me</button>
<script>
console.log('Welcome to 30DaysOfJavaScript')
console.log("Welcome to 30DaysOfJavaScript");
</script>
</body>
</html>
@ -387,7 +382,7 @@ Similar to the internal script, the external script link can be on the header or
First, we should create an external JavaScript file with .js extension. All files ending with .js extension are JavaScript files. Create a file named introduction.js inside your project directory and write the following code and link this .js file at the bottom of the body.
```js
console.log('Welcome to 30DaysOfJavaScript')
console.log("Welcome to 30DaysOfJavaScript");
```
External scripts in the _head_:
@ -412,7 +407,7 @@ External scripts in the _body_:
<title>30DaysOfJavaScript:External script</title>
</head>
<body>
<!-- JavaScript external link could be in the header or in the body -->
<!-- JavaScript external link could be in the header or in the body -->
<!-- Before the closing tag of the body is the recommended place to put the external JavaScript script -->
<scriptsrc="introduction.js"></script>
</body>
@ -427,7 +422,7 @@ We can also link multiple external JavaScript files to a web page.
Create a `helloworld.js` file inside the 30DaysOfJS folder and write the following code.
```js
console.log('Hello, World!')
console.log("Hello, World!");
```
```html
@ -467,16 +462,15 @@ A collection of one or more characters between two single quotes, double quotes,
**Example:**
```js
'a'
'Asabeneh'
"Asabeneh"
'Finland'
'JavaScript is a beautiful programming language'
'I love teaching'
'I hope you are enjoying the first day'
`We can also create a string using a backtick`
'A string could be just as small as one character or as big as many pages'
'Any data type under a single quote, double quote or backtick is a string'
"a";
"Asabeneh";
"Asabeneh";
"Finland";
"JavaScript is a beautiful programming language";
"I love teaching";
"I hope you are enjoying the first day"`We can also create a string using a backtick`;
("A string could be just as small as one character or as big as many pages");
("Any data type under a single quote, double quote or backtick is a string");
```
### Booleans
@ -488,8 +482,8 @@ A boolean data type is either a true or false value.
**Example:**
```js
true // if the light is on, the value is true
false // if the light is off, the value is false
true; // if the light is on, the value is true
false; // if the light is off, the value is false
```
### Undefined
@ -497,8 +491,8 @@ false // if the light is off, the value is false
In JavaScript, if we don't assign a value to a variable, the value is undefined. In addition to that, if a function is not returning anything, it returns undefined.
```js
let firstName
console.log(firstName) // undefined, because it is not assigned to a value yet
let firstName;
console.log(firstName); // undefined, because it is not assigned to a value yet
```
### Null
@ -506,7 +500,7 @@ console.log(firstName) // undefined, because it is not assigned to a value yet
Null in JavaScript means an empty value.
```js
let emptyValue = null
let emptyValue = null;
```
## Checking Data Types
@ -514,11 +508,11 @@ let emptyValue = null
To check the data type of a certain variable, we use the **typeof** operator. See the following example.
```js
console.log(typeof 'Asabeneh') // string
console.log(typeof 5) // number
console.log(typeof true) // boolean
console.log(typeof null) // object type
console.log(typeof undefined) // undefined
console.log(typeof "Asabeneh"); // string
console.log(typeof 5); // number
console.log(typeof true); // boolean
console.log(typeof null); // object type
console.log(typeof undefined); // undefined
```
## Comments Again
@ -562,25 +556,25 @@ A valid JavaScript variable name must follow the following rules:
The following are examples of valid JavaScript variables.
```js
firstName
lastName
country
city
capitalCity
age
isMarried
first_name
last_name
is_married
capital_city
num1
num_1
_num_1
$num1
year2020
year_2020
firstName;
lastName;
country;
city;
capitalCity;
age;
isMarried;
first_name;
last_name;
is_married;
capital_city;
num1;
num_1;
_num_1;
$num1;
year2020;
year_2020;
```
The first and second variables on the list follows the camelCase convention of declaring in JavaScript. In this material, we will use camelCase variables(camelWithOneHump). We use CamelCase(CamelWithTwoHump) to declare classes, we will discuss about classes and objects in other section.
@ -597,7 +591,7 @@ Let us declare variables with different data types. To declare a variable, we ne
```js
// Syntax
let nameOfVariable = value
let nameOfVariable = value;
```
The nameOfVriable is the name that stores different data of value. See below for detail examples.
@ -606,14 +600,14 @@ The nameOfVriable is the name that stores different data of value. See below for
```js
// Declaring different variables of different data types
let firstName = 'Asabeneh' // first name of a person
let lastName = 'Yetayeh' // last name of a person
let country = 'Finland' // country
let city = 'Helsinki' // capital city
let age = 100 // age in years
let isMarried = true
let firstName = "Asabeneh"; // first name of a person
let lastName = "Yetayeh"; // last name of a person
let country = "Finland"; // country
let city = "Helsinki"; // capital city
let age = 100; // age in years
let isMarried = true;
console.log(firstName, lastName, country, city, age, isMarried)
console.log(firstName, lastName, country, city, age, isMarried);
```
```sh
@ -622,11 +616,11 @@ Asabeneh Yetayeh Finland Helsinki 100 true
```js
// Declaring variables with number values
let age = 100 // age in years
const gravity = 9.81 // earth gravity in m/s2
const boilingPoint = 100 // water boiling point, temperature in °C
const PI = 3.14 // geometrical constant
console.log(gravity, boilingPoint, PI)
let age = 100; // age in years
const gravity = 9.81; // earth gravity in m/s2
const boilingPoint = 100; // water boiling point, temperature in °C