Skip to content

Commit

Permalink
corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Asabeneh committed Nov 17, 2021
1 parent b094b3f commit 97f84bf
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 97 deletions.
4 changes: 2 additions & 2 deletions 03_Day_Booleans_operators_date/03_booleans_operators_date.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ We agreed that boolean values are either true or false.
### Truthy values

- All numbers(positive and negative) are truthy except zero
- All strings are truthy
- All strings are truthy except an empty string ('')
- The boolean true

### Falsy values
Expand Down Expand Up @@ -616,7 +616,7 @@ console.log(`${date}/${month}/${year} ${hours}:${minutes}`) // 4/1/2020 0:56
1. Write a script that prompt the user to enter number of years. Calculate the number of seconds a person can live. Assume some one lives just hundred years

```sh
Enter number of yours you live: 100
Enter number of years you live: 100
You lived 3153600000 seconds.
```

Expand Down
5 changes: 3 additions & 2 deletions 06_Day_Loops/06_day_loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const numbers = [1, 2, 3, 4, 5]
const newArr = []
let sum = 0
for(let i = 0; i < numbers.length; i++){
newArr.push(i * i)
newArr.push( numbers[i] ** 2)

}

Expand Down Expand Up @@ -406,6 +406,7 @@ for(let i = 0; i <= 5; i++){
['Germany', 'GER', 7],
['Hungary', 'HUN', 7],
['Ireland', 'IRE', 7],
['Iceland', 'ICE', 7],
['Japan', 'JAP', 5],
['Kenya', 'KEN', 5]
]
Expand All @@ -414,7 +415,7 @@ for(let i = 0; i <= 5; i++){
2. In above countries array, check if there is a country or countries containing the word 'land'. If there are countries containing 'land', print it as array. If there is no country containing the word 'land', print 'All these countries are without land'.
```sh
['Finland', 'Iceland']
['Finland','Ireland', 'Iceland']
```
3. In above countries array, check if there is a country or countries end with a substring 'ia'. If there are countries end with, print it as array. If there is no country containing the word 'ai', print 'These are countries ends without ia'.
Expand Down
7 changes: 5 additions & 2 deletions 07_Day_Functions/07_day_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,13 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra

### Function declaration versus Arrow function

It ill be covered in other time
It Will be covered in other section.

🌕 You are a rising star, now you knew function . Now, you are super charged with the power of functions. You have just completed day 7 challenges and you are 7 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle.

## Testimony
Now it is time to express your thoughts about the Author and 30DaysOfJavaScript. You can leave your testimonial on this [link](https://testimonify.herokuapp.com/)

## 💻 Exercises

### Exercises: Level 1
Expand Down Expand Up @@ -617,7 +620,7 @@ It ill be covered in other time

### Exercises: Level 3

1. Modify question number n . Declare a function name _userIdGeneratedByUser_. It doesn’t take any parameter but it takes two inputs using prompt(). One of the input is the number of characters and the second input is the number of ids which are supposed to be generated.
1. Modify the _userIdGenerator_ function. Declare a function name _userIdGeneratedByUser_. It doesn’t take any parameter but it takes two inputs using prompt(). One of the input is the number of characters and the second input is the number of ids which are supposed to be generated.

```sh
userIdGeneratedByUser()
Expand Down
14 changes: 8 additions & 6 deletions 08_Day_Objects/08_day_objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Variables scopes can be:
Variable can be declared globally or locally or window scope. We will see both global and local scope.
Anything declared without let, var or const is scoped at window level.

Let us image we have a scope.js file.
Let us imagine that we have a scope.js file.

### Window Scope

Expand Down Expand Up @@ -102,23 +102,25 @@ let a = 'JavaScript' // is a global scope it will be found anywhere in this file
let b = 10 // is a global scope it will be found anywhere in this file
function letsLearnScope() {
console.log(a, b) // JavaScript 10, accessible
let c = 30
let value = false
if (true) {
// we can access from the function and outside the function but
// variables declared inside the if will not be accessed outside the if block
let a = 'Python'
let b = 20
let c = 30
let d = 40
value = !value
console.log(a, b, c) // Python 20 30
}
// we can not access c because c's scope is only the if block
console.log(a, b) // JavaScript 10
console.log(a, b, value) // JavaScript 10 true
}
letsLearnScope()
console.log(a, b) // JavaScript 10, accessible
```

Now, you have an understanding of scope. A variable declared with *var* only scoped to function but variable declared with *let* or *const* is block scope(function block, if block, loop etc). Block in JavaScript is a code in between two curly brackets ({}).
Now, you have an understanding of scope. A variable declared with *var* only scoped to function but variable declared with *let* or *const* is block scope(function block, if block, loop block, etc). Block in JavaScript is a code in between two curly brackets ({}).

```js
//scope.js
Expand Down Expand Up @@ -163,7 +165,7 @@ if (true){
for(let i = 0; i < 3; i++){
console.log(i) // 1, 2, 3
}
// console.log(i), Uncaught ReferenceError: gravity is not defined
// console.log(i), Uncaught ReferenceError: i is not defined

```

Expand Down Expand Up @@ -432,7 +434,7 @@ console.log(copyPerson.hasOwnProperty('score'))
### Exercises: Level 2

1. Find the person who has many skills in the users object.
1. Count logged in users,count users having greater than equal to 50 points from the following object.
1. Count logged in users, count users having greater than equal to 50 points from the following object.

````js
const users = {
Expand Down
53 changes: 23 additions & 30 deletions 09_Day_Higher_order_functions/09_day_higher_order_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,22 @@ const higherOrder = n => {
}
return doWhatEver
}
return doSomething
}
console.log(higherOrder(2)(3)(10))
```

Let us see were we use call back functions.For instance the _forEach_ method uses call back.
Let us see were we use call back functions. For instance the _forEach_ method uses call back.

```js
const numbers = [1, 2, 3, 4]
const sumArray = arr => {
let sum = 0
const callBack = function(element) {
const callback = function(element) {
sum += element
}
numbers.forEach(callback)
arr.forEach(callback)
return sum

}
Expand All @@ -115,7 +114,7 @@ const numbers = [1, 2, 3, 4]
const sumArray = arr => {
let sum = 0
numbers.forEach(function(element) {
arr.forEach(function(element) {
sum += element
})
return sum
Expand All @@ -128,20 +127,20 @@ console.log(sumArray(numbers))
15
```

### setting time
### Setting time

In JavaScript we can execute some activity on certain interval of time or we can schedule(wait) for sometime to execute some activities.
In JavaScript we can execute some activities in a certain interval of time or we can schedule(wait) for some time to execute some activities.

- setInterval
- setTimeout

#### setInterval
#### Setting Interaval using a setInterval function

In JavaScript, we use setInterval higher order function to do some activity continuously with in some interval of time. The setInterval global method take a callback function and a duration as a parameter. The duration is in milliseconds and the callback will be always called in that interval of time.

```js
// syntax
function callBack() {
function callback() {
// code goes here
}
setInterval(callback, duration)
Expand All @@ -151,10 +150,10 @@ setInterval(callback, duration)
function sayHello() {
console.log('Hello')
}
setInterval(sayHello, 2000) // it prints hello in every 2 seconds
setInterval(sayHello, 1000) // it prints hello in every second, 1000ms is 1s
```

#### setTimeout
#### Setting a time using a setTimeout

In JavaScript, we use setTimeout higher order function to execute some action at some time in the future. The setTimeout global method take a callback function and a duration as a parameter. The duration is in milliseconds and the callback wait for that amount of time.

Expand Down Expand Up @@ -195,9 +194,8 @@ arr.forEach((element, index, arr) => console.log(index, element, arr))

```js
let sum = 0;
const numbers = [1,2,3,4,5];
numbers.forEach(num => console.log(num)))

const numbers = [1, 2, 3, 4, 5];
numbers.forEach(num => console.log(num))
console.log(sum)
```

Expand All @@ -211,8 +209,8 @@ console.log(sum)

```js
let sum = 0;
const numbers = [1,2,3,4,5];
numbers.forEach(num => sum += num))
const numbers = [1, 2, 3, 4, 5];
numbers.forEach(num => sum += num)

console.log(sum)
```
Expand Down Expand Up @@ -349,6 +347,7 @@ console.log(countriesHaveFiveLetters)
```js
const scores = [
{ name: 'Asabeneh', score: 95 },
{ name: 'Lidiya', score: 98 },
{ name: 'Mathias', score: 80 },
{ name: 'Elias', score: 50 },
{ name: 'Martha', score: 85 },
Expand All @@ -360,7 +359,7 @@ console.log(scoresGreaterEight)
```

```sh
[{name: 'Asabeneh', score: 95}, {name: 'Martha', score: 85},{name: 'John', score: 100}]
[{name: 'Asabeneh', score: 95}, { name: 'Lidiya', score: 98 },{name: 'Martha', score: 85},{name: 'John', score: 100}]
```
### reduce
Expand Down Expand Up @@ -391,7 +390,7 @@ _every_: Check if all the elements are similar in one aspect. It returns boolean
```js
const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook']
const areAllStr = names.every((name) => typeof name === 'string')
const areAllStr = names.every((name) => typeof name === 'string') // Are all strings?
console.log(arrAllStr)
```
Expand All @@ -402,11 +401,9 @@ true
```js
const bools = [true, true, true, true]
const areAllTrue = bools.every((b) => {
return b === true
})
const areAllTrue = bools.every((b) => b === true) // Are all true?
console.log(areAllTrue) //true
console.log(areAllTrue) // true
```
```sh
Expand Down Expand Up @@ -448,9 +445,7 @@ const scores = [
{ name: 'John', score: 100 },
]
const score = scores.find((user) => {
return user.score > 80
})
const score = scores.find((user) => user.score > 80)
console.log(score)
```
Expand Down Expand Up @@ -481,15 +476,13 @@ _some_: Check if some of the elements are similar in one aspect. It returns bool
const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook']
const bools = [true, true, true, true]
const areSomeTrue = bools.some((b) => {
return b === true
})
const areSomeTrue = bools.some((b) => b === true)
console.log(areSomeTrue) //true
```
```js
const areAllStr = names.some((name) => typeof name === 'number')
const areAllStr = names.some((name) => typeof name === 'number') // Are all strings ?
console.log(areAllStr) // false
```
Expand Down Expand Up @@ -556,7 +549,7 @@ users.sort((a, b) => {
return 0
})
console.log(users) // sorted ascending
//[{…}, {…}, {…}, {…}]
// [{…}, {…}, {…}, {…}]
```
🌕 You are doing great.Never give up because great things take time. You have just completed day 9 challenges and you are 9 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle.
Expand Down
12 changes: 6 additions & 6 deletions 10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Set(6) {1, 2, 3, 4, 5,6}

### Intersection of sets

To find an intersection of two sets can be achieved using filter. Lets find the union of set A and set B (A ∩ B)
To find an intersection of two sets can be achieved using filter. Lets find the intersection of set A and set B (A ∩ B)

```js
let a = [1, 2, 3, 4, 5]
Expand Down Expand Up @@ -388,8 +388,8 @@ Norway Oslo
### Exercises:Level 1

```js
const a = {4, 5, 8, 9}
const b = {3, 4, 5, 7}
const a = [4, 5, 8, 9]
const b = [3, 4, 5, 7]
const countries = ['Finland', 'Sweden', 'Norway']
```

Expand Down Expand Up @@ -432,9 +432,9 @@ const countries = ['Finland', 'Sweden', 'Norway']
// Your output should look like this
console.log(mostSpokenLanguages(countries, 3))
[
{'English':91},
{'French':45},
{'Arabic':25}
{English:91},
{French:45},
{Arabic:25}
]
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const rectangle = {
height: 10,
area: 200
}
let { width: w, heigh: h, area: a, perimeter: p } = rectangle
let { width: w, height: h, area: a, perimeter: p } = rectangle

console.log(w, h, a, p)
```
Expand All @@ -226,7 +226,7 @@ const rectangle = {
height: 10,
area: 200
}
let { width, heigh, area, perimeter = 60 } = rectangle
let { width, height, area, perimeter = 60 } = rectangle

console.log(width, height, area, perimeter) //20 10 200 60
//Lets modify the object:width to 30 and perimeter to 80
Expand All @@ -239,8 +239,8 @@ const rectangle = {
area: 200,
perimeter: 80
}
let { width, heigh, area, perimeter = 60 } = rectangle
console.log(width, height, area, perimeter) //20 10 200 80
let { width, height, area, perimeter = 60 } = rectangle
console.log(width, height, area, perimeter) //30 10 200 80
```

Destructuring keys as a function parameters. Lets create a function which take a rectangle object and it return a perimeter of a rectangle.
Expand Down Expand Up @@ -695,4 +695,4 @@ const users = [
```
🎉 CONGRATULATIONS ! 🎉

[<< Day 10](../10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md) | [Day 12>>](../12_Day_Regular_expressions/12_day_regular_expressions.md)
[<< Day 10](../10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md) | [Day 12 >>](../12_Day_Regular_expressions/12_day_regular_expressions.md)
2 changes: 1 addition & 1 deletion 17_Day_Web_storages/17_day_web_storages.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

Web Storage(sessionStorage and localStorage) is a new HTML5 API offering important benefits over traditional cookies. Before HTML5, application data had to be stored in cookies, included in every server request. Web storage is more secure, and large amounts of data can be stored locally, without affecting website performance. The data storage limit of cookies in many web browsers is about 4 KB per cookie. We Storages can store far larger data (at least 5MB) and never transferred to the server. All sites from the same or one origin can store and access the same data.

The data being stored can be accessed using JavaScript, which gives you the ability to leverage client-side scripting to do many things that have traditionally involved server-side programming and relational databases. The are are two Web Storage objects:
The data being stored can be accessed using JavaScript, which gives you the ability to leverage client-side scripting to do many things that have traditionally involved server-side programming and relational databases. There are two Web Storage objects:

- sessionStorage
- localStorage
Expand Down
Loading

0 comments on commit 97f84bf

Please sign in to comment.