You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
3.3 KiB
122 lines
3.3 KiB
# Day 1 - Introduction
|
|
|
|
|
|
## [Exercise Level 1](#exercise-level-1)
|
|
|
|
### [< Home >](../README.md) | [Day 2 >>](./02_day_datatype.md)
|
|
### Exercise Level 1
|
|
|
|
1. Write a single line comment which says, _comments can make code readable_
|
|
2. Write another single comment which says, _Welcome to 30DaysOfJavaScript_
|
|
3. Write a multiline comment which says, _comments can make code readable, easy to reuse_
|
|
_and informative_
|
|
|
|
4. Create a variable.js file and declare variables and assign string, boolean, undefined and null data types
|
|
5. Create datatypes.js file and use the JavaScript **_typeof_** operator to check different data types. Check the data type of each variable
|
|
6. Declare four variables without assigning values
|
|
7. Declare four variables with assigned values
|
|
8. Declare variables to store your first name, last name, marital status, country and age in multiple lines
|
|
9. Declare variables to store your first name, last name, marital status, country and age in a single line
|
|
10. Declare two variables _myAge_ and _yourAge_ and assign them initial values and log to the browser console.
|
|
|
|
```sh
|
|
I am 25 years old.
|
|
You are 30 years old.
|
|
```
|
|
|
|
### Exercise Level 1
|
|
|
|
|
|
1. Write a single line comment which says, comments can make code readable
|
|
|
|
```js
|
|
// comments can make code readable
|
|
```
|
|
|
|
2. Write another single comment which says, Welcome to 30DaysOfJavaScript
|
|
|
|
```js
|
|
//Welcome to 30DaysOfJavaScript
|
|
```
|
|
|
|
3. Write a multiline comment which says, comments can make code readable, easy to reuse and informative
|
|
|
|
```js
|
|
/* comments can make code readable,
|
|
easy to reuse and informative */
|
|
```
|
|
|
|
4. Create a variable.js file and declare variables and assign string, boolean, undefined and null data types
|
|
|
|
```js
|
|
//variable.js
|
|
let string = 'nevzat'
|
|
let number = 25
|
|
let boolean = true
|
|
let nulll = null
|
|
let any; //undefined
|
|
```
|
|
|
|
5.Create datatypes.js file and use the JavaScript typeof operator to check different data types. Check the data type of each variable
|
|
|
|
```js
|
|
//variable.js
|
|
|
|
let string = 'nevzat'
|
|
let number = 25
|
|
let boolean = true
|
|
let nulll = null
|
|
let any;
|
|
|
|
console.log(typeof (string) ) //String
|
|
console.log(typeof (number)) //Number
|
|
console.log(typeof (boolean)) //Boolean
|
|
console.log(typeof (nulll)) //Object
|
|
console.log(typeof (any)) //Undefined
|
|
```
|
|
|
|
6. Declare four variables without assigning values
|
|
|
|
```js
|
|
let variable1;
|
|
let variable2;
|
|
var variable3;
|
|
let variable4;
|
|
```
|
|
|
|
7. Declare four variables with assigned values
|
|
|
|
```js
|
|
variable1 = "nevzat"
|
|
variable2 = "ATALAY"
|
|
variable3 = true;
|
|
variable4 = 25;
|
|
```
|
|
|
|
8. Declare variables to store your first name, last name, marital status, country and age in multiple lines
|
|
|
|
```js
|
|
let firstName = "nevzat"
|
|
let lastName = "atalay"
|
|
let old = 25
|
|
let isMarried = true
|
|
```
|
|
|
|
9. Declare variables to store your first name, last name, marital status, country and age in a single line
|
|
|
|
```js
|
|
let name = "nevzat",surName="atalay",age = 25, married = true
|
|
```
|
|
|
|
10. Declare two variables myAge and yourAge and assign them initial values and log to the browser console.
|
|
|
|
```js
|
|
let myAge= 25
|
|
let yourAge = 22
|
|
|
|
console.log("I am " + " " + myAge + " " + "years old.") // I am 25 years old.
|
|
console.log("You are" + " " + yourAge + " " + "years old.") // You are 22 years old.
|
|
```
|
|
|
|
## [< Home >](../README.md) | [Day 2 >>](./02_day_datatype.md)
|