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 quotes.
İndiyə qədər biz _console.log()_ istifadə edərək mətnin necə göstərildiyini gördük. Əgər biz _console.log()_ istifadə edərək mətni və ya sətri çap ediriksə, mətn tək dırnaqlar, qoşa dırnaqlar və ya əks dırnaqlar (backtick) içərisində olmalıdır.
İndi gəlin ədəd tipli dəyişənlər üzərində Google Chrome konsolunda _console.log()_ istifadə edərək JavaScript kodlarının yazılmasına aid nümunələri məşq edək.
Now, let us practice more writing JavaScript codes using _console.log()_ on google chrome console for number data types.
Mətnə əlavə olaraq JavaScript-dən istifadə edərək riyazi hesablamalar da edə bilərik. Aşağıdakı sadə hesablamaları aparaq.
In addition to the text, we can also do mathematical calculations using JavaScript. Let us do the following simple calculations.
Konsol **_console.log()_** funksiyası olmadan birbaşa arqumentlər qəbul edə bilər. Bununla belə, o, dərslikdə daha əvvəldə daxil edilmişdir, çünki bu nümunələrin əksəriyyəti funksiyadan istifadənin məcburi olduğu mətn redaktorunda baş verəcəkdir. Konsoldakı təlimatlarlı birbaşa nəzərdən keçirə bilərsiniz.
The console can directly take arguments without the **_console.log()_** function. However, it is included in this introduction because most of this challenge would be taking place in a text editor where the usage of the function would be mandatory. You can play around directly with instructions on the console.
We can write our codes on the browser console, but it won't do for bigger projects. In a real working environment, developers use different code editors to write their codes. In this 30 days JavaScript challenge, we will be using Visual Studio Code.
Kodlarımızı brauzer konsoluna yaza bilərik, lakin bu, daha böyük layihələr üçün əlverişli deyil və ya bəzi hallarda mümkünsüzdür. Real iş mühitində proqramçılar kodlarını yazmaq üçün müxtəlif kod/mətn redaktorlarından istifadə edirlər. Bu 30 günlük JavaScript dərsliyində biz Visual Studio Code-dan istifadə edəcəyik.
#### Installing Visual Studio Code
#### Visual Studio Code-un yüklənməsi
Visual studio code is a very popular open-source text editor. I would recommend to [download Visual Studio Code](https://code.visualstudio.com/), but if you are in favor of other editors, feel free to follow with what you have.
Visual Studio Code çox məşhur açıq mənbəli mətn redaktorudur. [Visual Studio Code-u yükləmə](https://code.visualstudio.com/) tövsiyə edərdim, lakin başqa redaktorların tərəfdarısınızsa, əlinizdə olanları istifadə etməkdən çəkinməyin.


If you installed Visual Studio Code, let us start using it.
Yüklədikdən sonra mətn redaktoru artıq istifadəyə hazırdır.
#### How to Use Visual Studio Code
#### Visual Studio Code-u necə istifadə etməli
Open the Visual Studio Code by double-clicking its icon. When you open it, you will get this kind of interface. Try to interact with the labeled icons.
Yüklənmə uğurla başa çatdıqdan sonra Visual Studio Code ikonuna 2 ardıcıl klik edərək onu başlada bilərsiniz
JavaScript can be added to a web page in three different ways:
JavaScript kodu veb səhifəyə 3 üsulla əlavə edilə bilər:
- **_Inline script_**
- **_Sətirdaxili skript_**
- **_Internal script_**
- **_Daxili skript_**
- **_External script_**
- **_Xarici fayl ilə skript_**
- **_Multiple External scripts_**
- **_Birneçə xarici faylla skript_**
The following sections show different ways of adding JavaScript code to your web page.
Aşağıdakı bölmələr veb səhifənizə JavaScript kodu əlavə etməyin müxtəlif yollarını göstərir.
### Inline Script
### Sətirdaxili skript
Create a project folder on your desktop or in any location, name it 30DaysOfJS and create an **_index.html_** file in the project folder. Then paste the following code and open it in a browser, for example [Chrome](https://www.google.com/chrome/).
İş masanızda və ya istənilən yerdə layihə qovluğu yaradın, onu 30DaysOfJS adlandırın və layihə qovluğunda **_index.html_** faylı yaradın. Sonra aşağıdakı kodu fayla əlavə edib onu brauzerdə açın, məsələn [Chrome](https://www.google.com/chrome/) ilə.
```html
```html
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>30DaysOfScript:Inline Script</title>
<title>30DaysOfScript: Sətirdaxili skript</title>
</head>
</head>
<body>
<body>
<buttononclick="alert('Welcome to 30DaysOfJavaScript!')">Click Me</button>
<buttononclick="alert('30DaysOfJavaScript dərsliyinə xoş gəlmişsiniz')">Kliklə</button>
</body>
</body>
</html>
</html>
```
```
Now, you just wrote your first inline script. We can create a pop up alert message using the _alert()_ built-in function.
İndi siz ilk daxili skriptinizi yazdınız. Biz _alert()_ daxili funksiyasından istifadə edərək pop-up xəbərdarlıq mesajı yarada bilərik.
### Internal Script
### Daxili skript
The internal script can be written in the _head_ or the _body_, but it is preferred to put it on the body of the HTML document.
Daxili skript _head_ və ya _body_ ilə yazıla bilər, lakin onu HTML sənədinin gövdəsinə yerləşdirməyə üstünlük verilir.
First, let us write on the head part of the page.
Əvvəlcə səhifənin baş hissəsinə yazaq.
```html
```html
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>30DaysOfScript:Internal Script</title>
<title>30DaysOfScript: Daxili skript</title>
<script>
<script>
console.log('Welcome to 30DaysOfJavaScript')
console.log('30DaysOfJavaScript-ə xoş gəlmişsiniz')
</script>
</script>
</head>
</head>
<body></body>
<body></body>
</html>
</html>
```
```
This is how we write an internal script most of the time. Writing the JavaScript code in the body section is the most preferred option. Open the browser console to see the output from the console.log()
Çox vaxt daxili skripti belə yazırıq. JavaScript kodunun faylın gövdəsinə (body) bölməsinə yazılması ən çox üstünlük verilən seçimdir. console.log() saytından çıxışı görmək üçün brauzer konsolunu açın
```html
```html
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>30DaysOfScript:Internal Script</title>
<title>30DaysOfScript: Daxili skript</title>
</head>
</head>
<body>
<body>
<buttononclick="alert('Welcome to 30DaysOfJavaScript!');">Click Me</button>
<buttononclick="alert('30DaysOfJavaScript-ə xoş gəlmişsiniz');">Kliklə</button>
<script>
<script>
console.log('Welcome to 30DaysOfJavaScript')
console.log('30DaysOfJavaScript-ə xoş gəlmişsiniz')
</script>
</script>
</body>
</body>
</html>
</html>
```
```
Open the browser console to see the output from the console.log()
console.log() saytından çıxışı görmək üçün brauzer konsolunu açın


### External Script
### Xarici kod skripti
Similar to the internal script, the external script link can be on the header or body, but it is preferred to put it in the body.
Daxili skriptə bənzər şəkildə, xarici skript bağlantısı başlıqda (head) və ya gövdədə (body) ola bilər, lakin onun gövdəyə yerləşdirilməsinə üstünlük verilir.
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.
Əvvəlcə .js uzantılı xarici JavaScript faylı yaratmalıyıq. .js uzantısı ilə bitən bütün fayllar JavaScript fayllarıdır. Layihə qovluğunda introduction.js adlı fayl yaradın və aşağıdakı kodu yazın və bu .js faylını gövdənin aşağı hissəsində əlaqələndirin.
```js
```js
console.log('Welcome to 30DaysOfJavaScript')
console.log('30 Günlük JS dərsləri')
```
```
External scripts in the _head_:
_head_ hissəsində JavaScript faylına istinad:
```html
```html
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>30DaysOfJavaScript:External script</title>
<title>30DaysOfJavaScript: Xarici skript faylı</title>
<scriptsrc="introduction.js"></script>
<scriptsrc="introduction.js"></script>
</head>
</head>
<body></body>
<body></body>
</html>
</html>
```
```
External scripts in the _body_:
_body_ hissəsində JavaScript faylına istinad:
```html
```html
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>30DaysOfJavaScript:External script</title>
<title>30DaysOfJavaScript: Xarici skript faylı</title>
</head>
</head>
<body>
<body>
<!--it could be in the header or in the body-->
<!--Əvvəldə vurğuladığımız kimi həm head həm body hissəsində ola bilər-->
<!--Here is the recommended place to put the external script-->
<!--Lakin aşağıda göstərilən kimi (body hissəsində) olması arzuolunandır-->
<scriptsrc="introduction.js"></script>
<scriptsrc="introduction.js"></script>
</body>
</body>
</html>
</html>
```
```
Open the browser console to see the output of the console.log()
console.log() nəticəsini görmək üçün brauzer konsolunu açın.
### Multiple External Scripts
### Birneçə xarici skript faylına istinad
We can also link multiple external JavaScript files to a web page.
Biz həmçinin bir neçə xarici JavaScript faylına veb səhifədə istinad edə bilərik.
Create a helloworld.js file inside the 30DaysOfJS folder and write the following code.
30DaysOfJS qovluğunda helloworld.js faylı yaradın və aşağıdakı kodu yazın.
```js
```js
console.log('Hello, World!')
console.log('Salam, dünya!')
```
```
```html
```html
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>Multiple External Scripts</title>
<title>Birneçə xarici skript faylına istinad</title>
</head>
</head>
<body>
<body>
<scriptsrc="./helloworld.js"></script>
<scriptsrc="helloworld.js"></script>
<scriptsrc="./introduction.js"></script>
<scriptsrc="introduction.js"></script>
</body>
</body>
</html>
</html>
```
```
_Your main.js file should be below all other scripts_. It is very important to remember this.
_Main.js_ faylınız bütün digər skriptlərdən sonra daxil edilməlidir. Bunu xatırlamaq çox vacibdir.


## Introduction to Data types
## Verilənlər tiplərinə giriş
In JavaScript and also other programming languages, there are different kinds of data types. The following are JavaScript primitive data types:_String, Number, Boolean, undefined, Null_, and_Symbol_.
JavaScript-də və digər proqramlaşdırma dillərində müxtəlif növ məlumat növləri mövcuddur. Aşağıdakılar JavaScript primitiv verilən tipləridir:_String, Number, Boolean, undefined, Null_ və_Symbol_.
### Numbers
### Ədədlər (Numbers)
- Integers: Integer (negative, zero and positive) numbers
- İnteger: Integer (mənfi, sıfır və müsbət) ədədlər
Example:
Nümunə:
... -3, -2, -1, 0, 1, 2, 3 ...
... -3, -2, -1, 0, 1, 2, 3 ...
- Float-point numbers: Decimal number
- Tam hissəli ədədlər: Onluq (Decimal) ədədlər
Example
Nümunə:
... -3.5, -2.25, -1.0, 0.0, 1.1, 2.2, 3.5 ...
... -3.5, -2.25, -1.0, 0.0, 1.1, 2.2, 3.5 ...
### Strings
### Sətir (String) tipli verilənlər
A collection of one or more characters between two single quotes, double quotes, or backticks.
İki tək dırnaq, qoşa dırnaq və ya əks istiqamətli dırnaqlar arasında bir və ya daha çox simvol çoxluğudur.
**Example:**
**Nümunə:**
```js
```js
'Asabeneh'
'Asabeneh'
@ -467,39 +470,37 @@ A collection of one or more characters between two single quotes, double quotes,
'A string could be just as small as one character as big as many pages'
'A string could be just as small as one character as big as many pages'
```
```
### Booleans
### Məntiqi ifadələr
A boolean value is either True or False. Any comparisons returns a boolean value, which is either true or false.
A boolean data type is either a true or false value.
Məntiqi tiplər yalnız iki mümkün qiymətdən birini ala bilən ifadələrdir. İstənilən müqayisə əməliyyatı_true_ və ya _false_ qiymətlərinin birindən ibarət nəticə qaytarır.
**Example:**
**Nümunə:**
```js
```js
true // if the light is on, the value is true
true
false // if the light is off, the value is false
false
```
```
### Undefined
### Undefined
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.
JavaScript-də dəyişənə ilkin qiymət təyin etməsək, _undefined_ tipi verilir. Bundan əlavə, funksiya heç nə qaytarmırsa, susmaya görə _undefined_ qaytarır.
```js
```js
let firstName
let firstName
console.log(firstName) // undefined, because it is not assigned to a value yet
console.log(firstName) // undefined, çünki dəyişənə ilkin qiymət təyin edilməyib
```
```
### Null
### Null
Null in JavaScript means an empty value.
JavaScript-də null boş dəyər deməkdir.
```js
```js
let emptyValue = null
let emptyValue = null
```
```
## Checking Data Types
## Verilənlər tiplərinin yoxlanılması
To check the data type of a certain variable, we use the **typeof** operator. See the following example.
Hər hansi müəyyən olunmuş dəyişənin tipini tapmaq üçün **typeof** operatoru istifadə oluna bilər. Nümunəyə nəzər yetirin.
```js
```js
console.log(typeof 'Asabeneh') // string
console.log(typeof 'Asabeneh') // string
@ -509,21 +510,20 @@ console.log(typeof null) // object type
console.log(typeof undefined) // undefined
console.log(typeof undefined) // undefined
```
```
## Comments Again
## Şərhlər (daha artıq)
Remember that commenting in JavaScript is similar to other programming languages. Comments are important in making your code more readable.
Bildiyimiz kimi JavaScript-də şərh yazmaq digər proqramlaşdırma dillərinə olduğu kimidir. Kodunuzu daha oxunaqlı etmək üçün şərhlər vacibdir.
There are two ways of commenting:
Şərh əlavə etməyin iki yolu var:
- _Single line commenting_
- _Təksətirli şərhlər_
- _Multiline commenting_
- _Çoxsətirli şərhlər_
```js
```js
// commenting the code itself with a single comment
// let firstName = 'Asabeneh'; tək sətirli şərh
// let firstName = 'Asabeneh'; single line comment
// let lastName = 'Yetayeh'; tək sətirli şərh
// let lastName = 'Yetayeh'; single line comment
```
```
Multiline commenting:
Çoxsətirli şərhlər:
```js
```js
/*
/*
@ -535,20 +535,20 @@ Multiline commenting:
*/
*/
```
```
## Variables
## Dəyişıənlər
Variables are _containers_ of data. Variables are used to _store_ data in a memory location. When a variable is declared, a memory location is reserved. When a variable is assigned to a value (data), the memory space will be filled with that data. To declare a variable, we use _var_, _let_, or _const_ keywords.
Dəyişənlər məlumatların yaddaşda saxlanması üçün istifadə olunur. Dəyişən elan edildikdə, yaddaş yeri rezerv olunur. Dəyişən təyin edildikdə, yaddaş sahəsində həmin verilənlər saxlanılır. Dəyişən elan etmək üçün biz _var_, _let_ və ya _const_ açar sözlərindən istifadə edirik.
For a variable that changes at a different time, we use _let_. If the data does not change at all, we use _const_. For example, PI, country name, gravity do not change, and we can use _const_. We will not use var in this challenge and I don't recommend you to use it. It is error prone way of declaring variable it has lots of leak. We will talk more about var, let, and const in detail in other sections (scope). For now, the above explanation is enough.
Qİyməti proqram daxilində dəyişən dəyişənlər üçün biz _let_ istifadə edirik. Məlumatlar ümumiyyətlə dəyişməzsə, yəni sabitlər üçün biz _const_ istifadə edirik. Məsələn, PI sabiti üçün biz _const_ istifadə edə bilərik. Bu dərslikdə _var_ istifadə etməyəcəyik və mən sizə ondan istifadə etməyi tövsiyə etmirəm. Bu, tövsiyə edilən yol deyil və təhlükəli məqamlara yol aça bilər. Var, let və const haqqında digər bölmələrdə ətraflı danışacağıq. Hələlik yuxarıdakı izahat kifayətdir.
A valid JavaScript variable name must follow the following rules:
Düzgün JavaScript dəyişən adı aşağıdakı qaydalara əməl etməlidir:
- A JavaScript variable name should not begin with a number.
- Rəqəmlə başlaya bilməz.
- A JavaScript variable name does not allow special characters except dollar sign and underscore.
- $ və _ istisna olmaqla xüsusi simvolların istifadəsinə icazə verilmir.
- A JavaScript variable name follows a camelCase convention.
- Adətən camelCase konvensiyasına əsaslanaraq adlandırılır.
- A JavaScript variable name should not have space between words.
- Sözlər və ya dəyişən adının hissələri arasında boşluq olmaz.
The following are examples of valid JavaScript variables.
Düzgün dəyişən adları nümunələri:
```js
```js
firstName
firstName
@ -572,9 +572,9 @@ year2020
year_2020
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.
Siyahıdakı birinci və ikinci dəyişənlər JavaScript-də elan etmək üçün camelCase konvensiyasına uyğundur. Bu dərslikdə biz camelCase dəyişənlərindən istifadə edəcəyik.
Example of invalid variables:
Yalnış elan olunmuş dəyişənlər:
```sh
```sh
first-name
first-name
@ -582,22 +582,22 @@ Example of invalid variables:
num_#_1
num_#_1
```
```
Let us declare variables with different data types. To declare a variable, we need to use _let_ or _const_ keyword before the variable name. Following the variable name, we write an equal sign (assignment operator), and a value(assigned data).
Müxtəlif verilən tipləri ilə dəyişənləri elan edək. Dəyişən elan etmək üçün dəyişən adından əvvəl _let_ və ya _const_ açar sözündən istifadə etməliyik. Dəyişən adından sonra bərabər işarəsi (təyinat operatoru) və dəyəri (təyin edilmiş verilənlər) yazırıq.
```js
```js
// Syntax
// Sintaksis
let nameOfVariable = value
let nameOfVariable = value
```
```
**Examples of declared variables**
**Nümunələr**
```js
```js
// Declaring different variables of different data types
// Müxtəlif verilənlər tipindən istifadə edərək dəyişənlərin yaradılmasə
let firstName = 'Asabeneh' // first name of a person
let firstName = 'Asabeneh' // ad
let lastName = 'Yetayeh' // last name of a person
let lastName = 'Yetayeh' // soyad
let country = 'Finland' // country
let country = 'Finland' // ölkə
let city = 'Helsinki' // capital city
let city = 'Helsinki' // paytaxt
let age = 100 // age in years
let age = 100 // yaş
let isMarried = true
let isMarried = true
console.log(firstName, lastName, country, city, age, isMarried)
console.log(firstName, lastName, country, city, age, isMarried)
@ -608,11 +608,11 @@ Asabeneh Yetayeh Finland Helsinki 100 true
```
```
```js
```js
// Declaring variables with number values
// ədəd tipli dəyişənlərin sabit açar sözü ilə yaradılması
let age = 100 // age in years
let age = 100 // yaş
const gravity = 9.81 // earth gravity in m/s2
const gravity = 9.81 // Fizikada istifadə olunan qravitasiya sabiti
const boilingPoint = 100 // water boiling point, temperature in °C
const boilingPoint = 100 // Normal atmosfer təzyiqində suyun qaynama tempraturu