Skip to content

Commit 56130ef

Browse files
committed
some corrections
1 parent d63dc55 commit 56130ef

File tree

24 files changed

+269
-249
lines changed

24 files changed

+269
-249
lines changed

02_Day_Data_types/02_day_data_types.md

+4
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ console.log(Math.E) // 2.718
231231
console.log(Math.log(2)) // 0.6931471805599453
232232
console.log(Math.log(10)) // 2.302585092994046
233233

234+
// Returns the natural logarithm of 2 and 10 respectively
235+
console.log(Math.LN2) // 0.6931471805599453
236+
console.log(Math.LN10) // 2.302585092994046
237+
234238
// Trigonometry
235239
Math.sin(0)
236240
Math.sin(60)

02_Day_Data_types/string_methods/match.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let pattern = /love/gi
1414
console.log(string.match(pattern)) // ["love", "love", "love"]
1515
// Let us extract numbers from text using regular expression. This is not regular expression section, no panic.
1616

17-
let txt = 'In 2019, I run 30 Days of Pyhton. Now, in 2020 I super exited to start this challenge'
17+
let txt = 'In 2019, I run 30 Days of Python. Now, in 2020 I super exited to start this challenge'
1818
let regEx = /\d/g // d with escape character means d not a normal d instead acts a digit
1919
// + means one or more digit numbers,
2020
// if there is g after that it means global, search everywhere.

02_Day_Data_types/string_methods/split.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// split(): The split method splits a string at a specified place.
2-
let string = '30 Days Of JavaScipt'
2+
let string = '30 Days Of JavaScript'
33
console.log(string.split()) // ["30 Days Of JavaScript"]
44
console.log(string.split(' ')) // ["30", "Days", "Of", "JavaScript"]
55
let firstName = 'Asabeneh'

03_Day_Booleans_operators_date/03_booleans_operators_date.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
- [Increment Operator](#increment-operator)
3232
- [Decrement Operator](#decrement-operator)
3333
- [Ternary Operators](#ternary-operators)
34-
- [Operator Precendence](#operator-precendence)
34+
- [Operator Precedence](#operator-precedence)
3535
- [Window Methods](#window-methods)
3636
- [Window alert() method](#window-alert-method)
3737
- [Window prompt() method](#window-prompt-method)
@@ -333,9 +333,9 @@ number > 0
333333
-5 is a negative number
334334
```
335335

336-
### Operator Precendence
336+
### Operator Precedence
337337

338-
I would like to recommend you to read about operator precendence from this [link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)
338+
I would like to recommend you to read about operator precedence from this [link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)
339339

340340
## Window Methods
341341

@@ -568,9 +568,9 @@ console.log(`${date}/${month}/${year} ${hours}:${minutes}`) // 4/1/2020 0:56
568568
1. Get length and width using prompt and calculate an area of rectangle (area = length x width and the perimeter of rectangle (perimeter = 2 x (length + width))
569569
1. Get radius using prompt and calculate the area of a circle (area = pi x r x r) and circumference of a circle(c = 2 x pi x r) where pi = 3.14.
570570
1. Calculate the slope, x-intercept and y-intercept of y = 2x -2
571-
1. Slope is (m = y2-y1/x2-x1). Find the slope between point (2, 2) and point(6,10)
571+
1. Slope is m = (y<sub>2</sub>-y<sub>1</sub>)/(x<sub>2</sub>-x<sub>1</sub>). Find the slope between point (2, 2) and point(6,10)
572572
1. Compare the slope of above two questions.
573-
1. Calculate the value of y (y = x^2 + 6x + 9). Try to use different x values and figure out at what x value y is 0.
573+
1. Calculate the value of y (y = x<sup>2</sup> + 6x + 9). Try to use different x values and figure out at what x value y is 0.
574574
1. Writ a script that prompt a user to enter hours and rate per hour. Calculate pay of the person?
575575

576576
```sh

04_Day_Conditionals/04_day_conditionals.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ isRaining
280280

281281
### Exercises: Level 1
282282

283-
1. Get user input using prompt(“Enter your age:”). If user is 18 or older , give feedback:'You are old enough to drive' but if not 18 give another feedback stating to wait for the number of years he neds to turn 18.
283+
1. Get user input using prompt(“Enter your age:”). If user is 18 or older , give feedback:'You are old enough to drive' but if not 18 give another feedback stating to wait for the number of years he needs to turn 18.
284284

285285
```sh
286286
Enter your age: 30

05_Day_Arrays/05_day_arrays.md

+36-36
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,35 @@
1818
![Day 5](../images/banners/day_1_5.png)
1919

2020
- [📔 Day 5](#-day-5)
21-
- [Arrays](#arrays)
22-
- [How to create an empty array](#how-to-create-an-empty-array)
23-
- [How to create an array with values](#how-to-create-an-array-with-values)
24-
- [Creating an array using split](#creating-an-array-using-split)
25-
- [Accessing array items using index](#accessing-array-items-using-index)
26-
- [Modifying array element](#modifying-array-element)
27-
- [Methods to manipulate array](#methods-to-manipulate-array)
28-
- [Array Constructor](#array-constructor)
29-
- [Creating static values with fill](#creating-static-values-with-fill)
30-
- [Concatenating array using concat](#concatenating-array-using-concat)
31-
- [Getting array length](#getting-array-length)
32-
- [Getting index an element in arr array](#getting-index-an-element-in-arr-array)
33-
- [Getting last index of an element in array](#getting-last-index-of-an-element-in-array)
34-
- [Checking array](#checking-array)
35-
- [Converting array to string](#converting-array-to-string)
36-
- [Joining array elements](#joining-array-elements)
37-
- [Slice array elements](#slice-array-elements)
38-
- [Splice method in array](#splice-method-in-array)
39-
- [Adding item to an array using push](#adding-item-to-an-array-using-push)
40-
- [Removing the end element using pop](#removing-the-end-element-using-pop)
41-
- [Removing an element from the beginning](#removing-an-element-from-the-beginning)
42-
- [Add an element from the beginning](#add-an-element-from-the-beginning)
43-
- [Reversing array order](#reversing-array-order)
44-
- [Sorting elements in array](#sorting-elements-in-array)
45-
- [Array of arrays](#array-of-arrays)
46-
- [💻 Exercise](#-exercise)
47-
- [Exercise: Level 1](#exercise-level-1)
48-
- [Exercise: Level 2](#exercise-level-2)
49-
- [Exercise: Level 3](#exercise-level-3)
21+
- [Arrays](#arrays)
22+
- [How to create an empty array](#how-to-create-an-empty-array)
23+
- [How to create an array with values](#how-to-create-an-array-with-values)
24+
- [Creating an array using split](#creating-an-array-using-split)
25+
- [Accessing array items using index](#accessing-array-items-using-index)
26+
- [Modifying array element](#modifying-array-element)
27+
- [Methods to manipulate array](#methods-to-manipulate-array)
28+
- [Array Constructor](#array-constructor)
29+
- [Creating static values with fill](#creating-static-values-with-fill)
30+
- [Concatenating array using concat](#concatenating-array-using-concat)
31+
- [Getting array length](#getting-array-length)
32+
- [Getting index an element in arr array](#getting-index-an-element-in-arr-array)
33+
- [Getting last index of an element in array](#getting-last-index-of-an-element-in-array)
34+
- [Checking array](#checking-array)
35+
- [Converting array to string](#converting-array-to-string)
36+
- [Joining array elements](#joining-array-elements)
37+
- [Slice array elements](#slice-array-elements)
38+
- [Splice method in array](#splice-method-in-array)
39+
- [Adding item to an array using push](#adding-item-to-an-array-using-push)
40+
- [Removing the end element using pop](#removing-the-end-element-using-pop)
41+
- [Removing an element from the beginning](#removing-an-element-from-the-beginning)
42+
- [Add an element from the beginning](#add-an-element-from-the-beginning)
43+
- [Reversing array order](#reversing-array-order)
44+
- [Sorting elements in array](#sorting-elements-in-array)
45+
- [Array of arrays](#array-of-arrays)
46+
- [💻 Exercise](#-exercise)
47+
- [Exercise: Level 1](#exercise-level-1)
48+
- [Exercise: Level 2](#exercise-level-2)
49+
- [Exercise: Level 3](#exercise-level-3)
5050

5151
# 📔 Day 5
5252

@@ -390,22 +390,22 @@ Check an element if it exist in an array.
390390
const fruits = ['banana', 'orange', 'mango', 'lemon']
391391
let index = fruits.indexOf('banana') // 0
392392

393-
if(index != -1){
394-
console.log('This fruit does exist in the array')
393+
if(index === -1){
394+
console.log('This fruit does not exist in the array')
395395
} else {
396-
console.log('This fruit does not exist in the array')
396+
console.log('This fruit does exist in the array')
397397
}
398398
// This fruit does exist in the array
399399

400400
// we can use also ternary here
401-
index != -1 ? console.log('This fruit does exist in the array'): console.log('This fruit does not exist in the array')
401+
index === -1 ? console.log('This fruit does not exist in the array'): console.log('This fruit does exist in the array')
402402

403403
// let us check if a avocado exist in the array
404404
let indexOfAvocado = fruits.indexOf('avocado') // -1, if the element not found index is -1
405-
if(indexOfAvocado!= -1){
406-
console.log('This fruit does exist in the array')
405+
if(indexOfAvocado === -1){
406+
console.log('This fruit does not exist in the array')
407407
} else {
408-
console.log('This fruit does not exist in the array')
408+
console.log('This fruit does exist in the array')
409409
}
410410
// This fruit does not exist in the array
411411
```

06_Day_Loops/06_day_loops.md

+14-12
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
![Day 5](../images/banners/day_1_6.png)
1919

2020
- [📔 Day 6](#-day-6)
21-
- [Loops](#loops)
22-
- [for Loop](#for-loop)
23-
- [while loop](#while-loop)
24-
- [do while loop](#do-while-loop)
25-
- [for of loop](#for-of-loop)
26-
- [break](#break)
27-
- [continue](#continue)
28-
- [💻 Exercises:Day 6](#-exercisesday-6)
29-
- [Exercises: Level 1](#exercises-level-1)
30-
- [Exercises: Level 2](#exercises-level-2)
31-
- [Exercises: Level 3](#exercises-level-3)
21+
- [Loops](#loops)
22+
- [for Loop](#for-loop)
23+
- [while loop](#while-loop)
24+
- [do while loop](#do-while-loop)
25+
- [for of loop](#for-of-loop)
26+
- [break](#break)
27+
- [continue](#continue)
28+
- [💻 Exercises:Day 6](#-exercisesday-6)
29+
- [Exercises: Level 1](#exercises-level-1)
30+
- [Exercises: Level 2](#exercises-level-2)
31+
- [Exercises: Level 3](#exercises-level-3)
3232

3333
# 📔 Day 6
3434

@@ -178,7 +178,9 @@ for (const num of numbers) {
178178
// adding all the numbers in the array
179179
let sum = 0
180180
for (const num of numbers) {
181-
sum = sum + num // can be also shorten like this, sum += num
181+
sum = sum + num
182+
// can be also shorten like this, sum += num
183+
// after this we will use the shorter synthax(+=, -=, *=, /= etc)
182184
}
183185
console.log(sum) // 15
184186

07_Day_Functions/07_day_functions.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ function sumAllNums() {
239239
console.log(arguments)
240240
}
241241

242-
sumAllNums(1, 2, 3, 4))
242+
sumAllNums(1, 2, 3, 4)
243243
// Arguments(4) [1, 2, 3, 4, callee: ƒ, Symbol(Symbol.iterator): ƒ]
244244

245245
```
@@ -269,7 +269,7 @@ console.log(sumAllNums(15, 20, 30, 25, 10, 33, 40)) // 173
269269
270270
const sumAllNums = (...args) => {
271271
// console.log(arguments), arguments object not found in arrow function
272-
// instead we use an a parameter followed by spread operator
272+
// instead we use a parameter followed by spread operator (...)
273273
console.log(args)
274274
}
275275

@@ -523,7 +523,7 @@ It Will be covered in other section.
523523
9. Density of a substance is calculated as follows:_density= mass/volume_. Write a function which calculates _density_.
524524
10. Speed is calculated by dividing the total distance covered by a moving object divided by the total amount of time taken. Write a function which calculates a speed of a moving object, _speed_.
525525
11. Weight of a substance is calculated as follows: _weight = mass x gravity_. Write a function which calculates _weight_.
526-
12. Temperature in oC can be converted to oF using this formula: _oF = (oC x 9/5) + 32_. Write a function which convert oC to oF _convertCelciusToFahrenheit_.
526+
12. Temperature in oC can be converted to oF using this formula: _oF = (oC x 9/5) + 32_. Write a function which convert oC to oF _convertCelsiusToFahrenheit_.
527527
13. Body mass index(BMI) is calculated as follows: _bmi = weight in Kg / (height x height) in m2_. Write a function which calculates _bmi_. BMI is used to broadly define different weight groups in adults 20 years old or older.Check if a person is _underweight, normal, overweight_ or _obese_ based the information given below.
528528

529529
- The same groups apply to both men and women.

08_Day_Objects/08_day_objects.md

+37-33
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,49 @@
1818
![Thirty Days Of JavaScript](../images/banners/day_1_8.png)
1919

2020
- [📔 Day 8](#-day-8)
21-
- [Scope](#scope)
22-
- [Window Scope](#window-scope)
23-
- [Global scope](#global-scope)
24-
- [Local scope](#local-scope)
25-
- [📔 Object](#-object)
26-
- [Creating an empty object](#creating-an-empty-object)
27-
- [Creating an objecting with values](#creating-an-objecting-with-values)
28-
- [Getting values from an object](#getting-values-from-an-object)
29-
- [Creating object methods](#creating-object-methods)
30-
- [Setting new key for an object](#setting-new-key-for-an-object)
31-
- [Object Methods](#object-methods)
32-
- [Getting object keys using Object.keys()](#getting-object-keys-using-objectkeys)
33-
- [Getting object values using Object.values()](#getting-object-values-using-objectvalues)
34-
- [Getting object keys and values using Object.entries()](#getting-object-keys-and-values-using-objectentries)
35-
- [Checking properties using hasOwnProperty()](#checking-properties-using-hasownproperty)
36-
- [💻 Exercises](#-exercises)
37-
- [Exercises: Level 1](#exercises-level-1)
38-
- [Exercises: Level 2](#exercises-level-2)
39-
- [Exercises: Level 3](#exercises-level-3)
21+
- [Scope](#scope)
22+
- [Window Global Object](#window-global-object)
23+
- [Global scope](#global-scope)
24+
- [Local scope](#local-scope)
25+
- [📔 Object](#-object)
26+
- [Creating an empty object](#creating-an-empty-object)
27+
- [Creating an objecting with values](#creating-an-objecting-with-values)
28+
- [Getting values from an object](#getting-values-from-an-object)
29+
- [Creating object methods](#creating-object-methods)
30+
- [Setting new key for an object](#setting-new-key-for-an-object)
31+
- [Object Methods](#object-methods)
32+
- [Getting object keys using Object.keys()](#getting-object-keys-using-objectkeys)
33+
- [Getting object values using Object.values()](#getting-object-values-using-objectvalues)
34+
- [Getting object keys and values using Object.entries()](#getting-object-keys-and-values-using-objectentries)
35+
- [Checking properties using hasOwnProperty()](#checking-properties-using-hasownproperty)
36+
- [💻 Exercises](#-exercises)
37+
- [Exercises: Level 1](#exercises-level-1)
38+
- [Exercises: Level 2](#exercises-level-2)
39+
- [Exercises: Level 3](#exercises-level-3)
4040

4141
# 📔 Day 8
4242

4343
## Scope
4444

45-
Variable is the fundamental part in programming. We declare variable to store different data types. To declare a variable we use the key word _var_, _let_ and _const_. A variable can declared at different scope. In this section we will see the scope, scope of variables when we use var or let.
45+
Variable is the fundamental part in programming. We declare variable to store different data types. To declare a variable we use the key word _var_, _let_ and _const_. A variable can be declared at different scope. In this section, we will see the scope variables, scope of variables when we use var or let.
4646
Variables scopes can be:
4747

48-
- Window
4948
- Global
5049
- Local
5150

52-
Variable can be declared globally or locally or window scope. We will see both global and local scope.
53-
Anything declared without let, var or const is scoped at window level.
51+
Variable can be declared globally or locally scope. We will see both global and local scope.
52+
Anything declared without let, var or const is scoped at global level.
5453

5554
Let us imagine that we have a scope.js file.
5655

57-
### Window Scope
56+
### Window Global Object
5857

5958
Without using console.log() open your browser and check, you will see the value of a and b if you write a or b on the browser. That means a and b are already available in the window.
6059

6160
```js
6261
//scope.js
63-
a = 'JavaScript' // is a window scope this found anywhere
64-
b = 10 // this is a window scope variable
62+
a = 'JavaScript' // declaring a variable without let or const make it available in window object and this found anywhere
63+
b = 10 // this is a global scope variable and found in the window object
6564
function letsLearnScope() {
6665
console.log(a, b)
6766
if (true) {
@@ -96,13 +95,18 @@ console.log(a, b) // JavaScript 10, accessible
9695

9796
A variable declared as local can be accessed only in certain block code.
9897

98+
- Block Scope
99+
- Function Scope
100+
99101
```js
100102
//scope.js
101103
let a = 'JavaScript' // is a global scope it will be found anywhere in this file
102104
let b = 10 // is a global scope it will be found anywhere in this file
105+
// Function scope
103106
function letsLearnScope() {
104107
console.log(a, b) // JavaScript 10, accessible
105108
let value = false
109+
// block scope
106110
if (true) {
107111
// we can access from the function and outside the function but
108112
// variables declared inside the if will not be accessed outside the if block
@@ -111,7 +115,7 @@ function letsLearnScope() {
111115
let c = 30
112116
let d = 40
113117
value = !value
114-
console.log(a, b, c) // Python 20 30
118+
console.log(a, b, c, value) // Python 20 30 true
115119
}
116120
// we can not access c because c's scope is only the if block
117121
console.log(a, b, value) // JavaScript 10 true
@@ -138,9 +142,9 @@ if (true){
138142
console.log(gravity) // 9.81
139143

140144
for(var i = 0; i < 3; i++){
141-
console.log(i) // 1, 2, 3
145+
console.log(i) // 0, 1, 2
142146
}
143-
console.log(i)
147+
console.log(i) // 3
144148

145149
```
146150

@@ -163,13 +167,13 @@ if (true){
163167
// console.log(gravity), Uncaught ReferenceError: gravity is not defined
164168

165169
for(let i = 0; i < 3; i++){
166-
console.log(i) // 1, 2, 3
170+
console.log(i) // 0, 1, 2
167171
}
168172
// console.log(i), Uncaught ReferenceError: i is not defined
169173

170174
```
171175

172-
The scope *let* and *const* is the same. The difference is only reassigning. We can not change or reassign the value of const variable. I would strongly suggest you to use *let* and *const*, by using *let* and *const* you will writ clean code and avoid hard to debug mistakes. As a rule of thumb, you can use *let* for any value which change, *const* for any constant value, and for array, object, arrow function and function expression.
176+
The scope *let* and *const* are the same. The difference is only reassigning. We can not change or reassign the value of the `const` variable. I would strongly suggest you to use *let* and *const*, by using *let* and *const* you will write clean code and avoid hard to debug mistakes. As a rule of thumb, you can use *let* for any value which change, *const* for any constant value, and for an array, object, arrow function and function expression.
173177

174178
## 📔 Object
175179

@@ -252,14 +256,14 @@ const person = {
252256
console.log(person.firstName)
253257
console.log(person.lastName)
254258
console.log(person.age)
255-
console.log(person.location)
259+
console.log(person.location) // undefined
256260

257261
// value can be accessed using square bracket and key name
258262
console.log(person['firstName'])
259263
console.log(person['lastName'])
260264
console.log(person['age'])
261265
console.log(person['age'])
262-
console.log(person['location'])
266+
console.log(person['location']) // undefined
263267

264268
// for instance to access the phone number we only use the square bracket method
265269
console.log(person['phone number'])

0 commit comments

Comments
 (0)