You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -172,23 +172,7 @@ let personInfoTwo = `I am ${fullName}.I am ${age}. I live in ${country}`; //ES6
172
172
let personInfoThree =`I am ${fullName}. I live in ${country}, ${city}. I am a ${job}. I teach ${language}.`
173
173
console.log(personInfoOne);
174
174
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
-
189
175
```
190
-
191
-
192
176
#### Exercise - 3 : String
193
177
1. Declare a variable name company and assign it to an initial value **"Coding Academy"**.
194
178
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
216
200
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'*
217
201
1. Use *concat()* and merge 'Coding' and 'Academy' to a single string, 'Coding Academy'
218
202
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.'
219
204
220
205
### Numbers
221
206
Numbers are integers and decimal values which can do all the arithemtic operations
222
207
Lets' see some examples of Numbers
223
208
```js
224
209
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
+
constPI=3.14;// constant
213
+
214
+
//More Examples
215
+
constboilingPoint=100; // oC, boiling point of water
constboilingPoint=100;// temperature in oC, boiling point of water
279
+
constbodyTemp=37; // body temperature in oC
280
+
281
+
//Lets calculate area of a circle
282
+
constareaOfCircle=PI* radius * radius;
283
+
console.log(areaOfCircle) // -> 314 m
284
+
// Lets calculate weight of a substance
285
+
constweight= 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
+
);
282
296
```
283
297
#### Exercises:Arthimetic Operators:
284
298
JavaScript arithmetic operators are addition(+), subtraction(-), multiplication(*), division(/), modulus(%), increment(++) and decrement(--).
@@ -397,6 +411,18 @@ console.log(shoppingCart)
397
411
1. Remove the middle IT company or companies from the array
398
412
1. Remove the last IT company from the array
399
413
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’.
1. Area of a circle is calculated as follows: *area = π x r x r*. Write a function which calculates *areaOfCircle*
677
703
1. Circumference of a circle is calculated as follows: *circumference = 2πr*. Write a function which calculates *circumOfCircle*
678
704
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*.
679
706
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*.
689
715
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).
691
717
1. Declare a function name *capitalizeArray*. It takes array as a parameter and it returns the - capitalizedarray.
692
718
1. Declare a function name *addItem*. It takes an item parameter and it returns an array after adding the item
693
719
1. Declare a function name *removeItem*. It takes an index parameter and it returns an array after removing an item
694
720
1. Declare a function name *sumOfNumbers*. It takes a number parameter and it adds all the numbers in that range.
695
721
1. Declare a function name *sumOfOdds*. It takes a number parameter and it adds all the odd numbers in that - range.
696
722
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.
698
724
output:
699
725
```she
700
726
evensAndOdds(100);
701
727
The number of odds are 50.
702
728
The number of evens are 51.
703
729
```
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.
705
736
output:
706
737
```she
707
738
console.log(randomHexaNumberGenerator());
708
739
'#ee33df'
709
740
```
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.
711
742
Output:
712
743
```sh
713
744
console.log(userIdGenerator());
714
745
41XTDbE
715
746
```
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.
717
748
```sh
718
749
userIdGeneratedByUser()
719
750
"kcsy2
@@ -730,13 +761,13 @@ UbGxOFI7UXSWAyKN
730
761
dIV0SSUTgAdKwStr
731
762
"
732
763
```
733
-
- Write a function name *rgbColorGenerator* and it generates rgb colors.
764
+
1. Write a function name *rgbColorGenerator* and it generates rgb colors.
734
765
Output:
735
766
```sh
736
767
rgb(125,244,255)
737
768
```
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.
0 commit comments