Skip to content

Commit 7ef85c2

Browse files
committed
section added
1 parent 4cbcbee commit 7ef85c2

1 file changed

Lines changed: 69 additions & 38 deletions

File tree

readMe.md

Lines changed: 69 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
13. [Class](#class)
1717
14. [Document Object Model](#dom)
1818
15. [Functional Programming](#functional-programming)
19-
16. [Call Back and Higher Order Functions](#callback-and-higher-order-functions)
19+
16. [Call Back and Higher Order Functions](#call-back-and-higher-order-functions)
2020
17. [Destructuring](#destructuring)
2121
19. [Rest and Spread](#rest-and-spread)
2222
20. [Document Object Model](#document-object-model)
2323
21. [Regular Expressions](#regular-expressions)
24-
22. [LocalStorage](#localstorage)
24+
22. [Local Storage](#localstorage)
2525
23. [Cookies](#cookies)
2626

2727
## Introduction
@@ -172,23 +172,7 @@ let personInfoTwo = `I am ${fullName}.I am ${age}. I live in ${country}`; //ES6
172172
let personInfoThree = `I am ${fullName}. I live in ${country}, ${city}. I am a ${job}. I teach ${language}.`
173173
console.log(personInfoOne);
174174
console.log(personInfoTwo);
175-
//More Examples
176-
var gravity = 9.81;
177-
var boilingPoint = 100;
178-
var bodyTemp = 37;
179-
180-
/*
181-
The boiling point of water is 100 oC.
182-
Human body temperatue is 37 oC.
183-
The gravity of earth is 9.81 m/s2.
184-
*/
185-
console.log(`The boiling point of water is ${boilingPoint} oC.\nHuman body temperatue is ${body} oC.\nThe gravity of earth is ${gravity} m / s2.`
186-
);
187-
188-
189175
```
190-
191-
192176
#### Exercise - 3 : String
193177
1. Declare a variable name company and assign it to an initial value **"Coding Academy"**.
194178
1. Print the string on the browser console using *console.log()*
@@ -216,15 +200,21 @@ console.log(`The boiling point of water is ${boilingPoint} oC.\nHuman body tempe
216200
1. Use *match()* to count the number all because's in the following sentence:*'You cannot end a sentence with because because because is a conjunction'*
217201
1. Use *concat()* and merge 'Coding' and 'Academy' to a single string, 'Coding Academy'
218202
1. Use *repeat()* method to print Coding Academy 5 times
203+
1. Calculate the total annual income of the person by extract the numbers from the following text. 'He earns 5000 euro from salary per month, 10000 euro annual bonus, 15000 euro online courses per month.'
219204

220205
### Numbers
221206
Numbers are integers and decimal values which can do all the arithemtic operations
222207
Lets' see some examples of Numbers
223208
```js
224209
let age = 35;
225-
let gravity = 9.81;
226-
let pi = 3.14;
227-
let temperature = 37;
210+
let gravity = 9.81; // m/s2
211+
let mass = 72 // keg
212+
const PI = 3.14;// constant
213+
214+
//More Examples
215+
const boilingPoint = 100; // oC, boiling point of water
216+
var bodyTemp = 37; // oc body temperature
217+
console.log(age, gravity, mass, PI, boilingPoint,bodyTemp)
228218

229219
```
230220
### Booleans
@@ -278,7 +268,31 @@ let diff = numOne - numTwo;
278268
let mult = numOne * numTwo;
279269
let div = numOne / numTwo;
280270
let remainder = numOne % numTwo;
271+
console.log(sum, diff,mult,div,remainder) // ->7,1,12,1.33,1
272+
273+
let PI = 3.14;
274+
let radius = 100;// length in meter
281275

276+
const gravity = 9.81; // in m/s2
277+
let mass = 72; // in Killogram
278+
const boilingPoint = 100;// temperature in oC, boiling point of water
279+
const bodyTemp = 37; // body temperature in oC
280+
281+
//Lets calculate area of a circle
282+
const areaOfCircle = PI * radius * radius;
283+
console.log(areaOfCircle) // -> 314 m
284+
// Lets calculate weight of a substance
285+
const weight = mass * gravity;
286+
console.log(weigth) // -> 706.32 N(Newton)
287+
288+
//Concatinating string with numbers using string interpolation
289+
/*
290+
The boiling point of water is 100 oC.
291+
Human body temperatue is 37 oC.
292+
The gravity of earth is 9.81 m/s2.
293+
*/
294+
console.log(`The boiling point of water is ${boilingPoint} oC.\nHuman body temperatue is ${body} oC.\nThe gravity of earth is ${gravity} m / s2.`
295+
);
282296
```
283297
#### Exercises:Arthimetic Operators:
284298
JavaScript arithmetic operators are addition(+), subtraction(-), multiplication(*), division(/), modulus(%), increment(++) and decrement(--).
@@ -397,6 +411,18 @@ console.log(shoppingCart)
397411
1. Remove the middle IT company or companies from the array
398412
1. Remove the last IT company from the array
399413
1. Remove all IT companies
414+
## More on Arrays
415+
Write a function called *modifyArray* takes array as parameter and modifies the fifth item of the array and returns the array. If the array length is less than five it return ‘item not found’.
416+
```js
417+
console.log(modifyArray(["Avocado", "Tomato", "Potato","Mango", "Lemon","Carrot"]);
418+
// →["Avocado", "Tomato", "Potato","Mango", "LEMON", "Carrot"]
419+
console.log(modifyArray(["Google", "Facebook","Apple", "Amazon","Microsoft", "IBM"]);
420+
// →["Google", "Facebook","Apple", "Amazon","MICROSOFT", "IBM"]
421+
console.log(modifyArray(["Google", "Facebook","Apple", "Amazon"]);
422+
// →"Not Found"
423+
424+
```
425+
400426
401427
## Conditionals
402428
#### If
@@ -676,44 +702,49 @@ const square = n => n * n;
676702
1. Area of a circle is calculated as follows: *area = π x r x r*. Write a function which calculates *areaOfCircle*
677703
1. Circumference of a circle is calculated as follows: *circumference = 2πr*. Write a function which calculates *circumOfCircle*
678704
1. Density of a substance is calculated as follows:*density= mass/volume*. Write a function which calculates *density*.
705+
1. Speed is calculated by dividing the total distance covered by a moving object divided by the total amount of time taken. Write a fucntion which calculates a speed of a moving object, *speed*.
679706
1. Weight of a substance is calculated as follows: *weight = mass x gravity*. Write a function which calculates *weight*.
680-
1. Body mass index(BMI) is calculated as follows: *bmi = weight in Kg / (height x height) in m2*. Write a function which calculates *bmi*.
681-
BMI is used to broadly define different weight groups in adults 20 years old or older.
682-
The same groups apply to both men and women.
683-
Underweight: BMI is less than 18.5
684-
Normal weight: BMI is 18.5 to 24.9
685-
Overweight: BMI is 25 to 29.9
686-
Obese: BMI is 30 or more
687-
1. Linear equation is calculated as follows: *f(x) = ax + b*. Write a function which calculates value of a linear equation, *solvLinEquation*.
688-
1. Quadratic equation is calculated as follows: *f(x) = ax2 + bx + c*. Write a function which calculates value or values of a quadratic equation, *solvQuadEquation*.
707+
1. 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 *obsese* based the information given below.
708+
- The same groups apply to both men and women.
709+
- *Underweight*: BMI is less than 18.5
710+
- *Normal weight*: BMI is 18.5 to 24.9
711+
- *Overweight*: BMI is 25 to 29.9
712+
- *Obese*: BMI is 30 or more
713+
1. Linear equation is calculated as follows: *ax + b = c*. Write a function which calculates value of a linear equation, *solvLinEquation*.
714+
1. Quadratic equation is calculated as follows: *ax2 + bx + c = 0*. Write a function which calculates value or values of a quadratic equation, *solvQuadEquation*.
689715
1. Declare a function name *printArray*. It takes array as a parameter and it prints out each value of thearray.
690-
1. Declare a function name *reverseArray*. It takes array as a parameter and it returns the reverse of the arra- (dont’ use method).
716+
1. Declare a function name *reverseArray*. It takes array as a parameter and it returns the reverse of the array (dont’ use method).
691717
1. Declare a function name *capitalizeArray*. It takes array as a parameter and it returns the - capitalizedarray.
692718
1. Declare a function name *addItem*. It takes an item parameter and it returns an array after adding the item
693719
1. Declare a function name *removeItem*. It takes an index parameter and it returns an array after removing an item
694720
1. Declare a function name *sumOfNumbers*. It takes a number parameter and it adds all the numbers in that range.
695721
1. Declare a function name *sumOfOdds*. It takes a number parameter and it adds all the odd numbers in that - range.
696722
1. Declare a function name *sumOfEven*. It takes a number parameter and it adds all the even numbers in that - range.
697-
1. Declare a function name . It takes a number parameter and it counts number of evens and odds in the - number.
723+
1. Declare a function name evensAndOdds . It takes a positive integer as parameter and it counts number of evens and odds in the number.
698724
output:
699725
```she
700726
evensAndOdds(100);
701727
The number of odds are 50.
702728
The number of evens are 51.
703729
```
704-
- Declare a function name *randomHexaNumberGenerator*. When this function is called it generates a random hexadecimal number. The function return the hexadecimal number.
730+
1. Write a funcition which takes any number of arguments and return the sum of the arguments
731+
```js
732+
sum(1,2,3) // -> 6
733+
sum(1,2,3,4) // -> 10
734+
```
735+
1. Declare a function name *randomHexaNumberGenerator*. When this function is called it generates a random hexadecimal number. The function return the hexadecimal number.
705736
output:
706737
```she
707738
console.log(randomHexaNumberGenerator());
708739
'#ee33df'
709740
```
710-
- Declare a function name *userIdGenerator*. When this function is called it generates seven character id. The function return the id.
741+
1. Declare a function name *userIdGenerator*. When this function is called it generates seven character id. The function return the id.
711742
Output:
712743
```sh
713744
console.log(userIdGenerator());
714745
41XTDbE
715746
```
716-
- 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.
747+
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.
717748
```sh
718749
userIdGeneratedByUser()
719750
"kcsy2
@@ -730,13 +761,13 @@ UbGxOFI7UXSWAyKN
730761
dIV0SSUTgAdKwStr
731762
"
732763
```
733-
- Write a function name *rgbColorGenerator* and it generates rgb colors.
764+
1. Write a function name *rgbColorGenerator* and it generates rgb colors.
734765
Output:
735766
```sh
736767
rgb(125,244,255)
737768
```
738-
- Write a function name *displayDateTime* and it display in this format: 28/08/2018 04:08
739-
- Use the new Date() object to get month, date, year, hour and minute.
769+
1. Write a function name *displayDateTime* and it display in this format: 28/08/2018 04:08
770+
1. Use the new Date() object to get month, date, year, hour and minute.
740771
Output:
741772
```sh
742773
28/08/2018 04:08

0 commit comments

Comments
 (0)