- [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)
@ -372,10 +372,10 @@ console.log('Welcome to 30DaysOfJavaScript')
打开浏览器控制台,查看 console.log() 的输出。
### Multiple External Scripts
### 多个外部脚本
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.
我们还可以将多个外部 JavaScript 文件链接到一个网页上。
在30DaysOfJS文件夹内创建一个helloworld.js文件,并编写以下代码。
```js
console.log('Hello, World!')
@ -394,27 +394,27 @@ console.log('Hello, World!')
</html>
```
_Your main.js file should be below all other scripts_. It is very important to remember this.
_你的 main.js 文件应该在所有其他脚本的下面_。记住这一点是非常重要的。

## Introduction to Data types
## 数据类型介绍
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_.
- Integers: Integer (negative, zero and positive) numbers
Example:
- Integers: 整数(负数、零数和正数)。
例如:
... -3, -2, -1, 0, 1, 2, 3 ...
- Float-point numbers: Decimal number
Example
- Float-point numbers: 小数点后的数字
例如:
... -3.5, -2.25, -1.0, 0.0, 1.1, 2.2, 3.5 ...
### Strings
### 字符串
A collection of one or more characters between two single quotes, double quotes, or backticks.
**Example:**
两个单引号、双引号或反斜线之间的一个或多个字符的集合。
**例如:**
```js
'Asabeneh'
@ -425,13 +425,13 @@ 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')
```
### Booleans
### 布尔值
A boolean value is either True or False. Any comparisons return a boolean value, which is either true or false.
一个布尔值要么是真,要么是假。任何比较都会返回一个布尔值,即真或假。
A boolean data type is either a true or false value.
布尔数据类型是一个真或假的值。
**Example:**
**例如:**
```js
true // if the light on ,the value is true
@ -440,7 +440,7 @@ false // if the light off, the value is false
### 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.
@ -449,15 +449,15 @@ console.log(firstName) //not defined, because it is not assigned to a value yet
### Null
Null in JavaScript means an empty value.
在 JavaScript 中,Null意味着一个空值。
```js
let emptyValue = null
```
## Checking Data Types
## 检测数据类型
To check the data type of a certain variable, we use the **typeof** operator. See the following example.
为了检测某个变量的数据类型,我们使用**typeof**操作符。请看下面的例子。
```js
console.log(typeof 'Asabeneh') // string
@ -467,13 +467,13 @@ console.log(typeof null) // object type
console.log(typeof undefined) // undefined
```
## Comments Again
## 再次强调注释
Remember that commenting in JavaScript is similar to other programming languages. Comments are important in making your code more readable.
There are two ways of commenting:
记住,JavaScript 中的注释与其他编程语言类似。注释对于使你的代码更具有可读性非常重要。
有两种注释的方式。
- _Single line commenting_
- _Multiline commenting_
- _单行注释_
- _多行注释_
```js
// commenting the code itself with a single comment
@ -481,7 +481,7 @@ There are two ways of commenting:
// let lastName = 'Yetayeh'; single line comment
```
Multiline commenting:
多行注释:
```js
/*
@ -492,20 +492,20 @@ Multiline commenting:
*/
```
## Variables
## 变量
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.
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 no 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.