@@ -2,10 +2,10 @@ export const metadata = {
22 title: " Primitives | Challenges" ,
33}
44
5- ### 1. Swap two integers present in variables num1 and num2 without using temporary variable
5+ ### 1. Swap two integers present in variables num1 and num2 without using a temporary variable
66
7- - The swapping of 2 variables is possible with simple Destructuring assignment using array
8- - Traditional approach of swapping by using the given variables is also achievable
7+ - The swapping of 2 variables is possible with simple Destructuring assignment using an array
8+ - The traditional approach of swapping by using the given variables is also achievable
99
1010``` js copy
1111let num1 = 10 , num2 = 20 ;
@@ -21,11 +21,11 @@ num1 = num1 - num2;
2121
2222** Notes**
2323
24- 2nd solution can fail due to overflow of number range if the numbers are very big
24+ 2nd solution can fail due to overflow of the number range if the numbers are very big
2525
2626---
2727
28- ### 2. Write a function which returns true if given value of number is an integer without using any inbuilt functions
28+ ### 2. Write a function that returns true if the given value of a number is an integer without using any inbuilt functions
2929
3030``` js copy
3131// Example
@@ -34,7 +34,7 @@ isInt(12.2); // false
3434isInt (0.3 ); // false
3535```
3636
37- - Modulo operator can be used to check if there is a remainder left when divided by 1
37+ - The modulo operator can be used to check if there is a remainder left when divided by 1
3838
3939``` js copy
4040function isInt (value ) {
@@ -44,13 +44,13 @@ function isInt(value) {
4444
4545---
4646
47- ### 3. Create a function which returns a random number in the given range of values both inclusive
47+ ### 3. Create a function that returns a random number in the given range of values, both inclusive
4848
4949- ` Math.random ` function returns a floating-point, pseudo-random number between 0 (inclusive) and 1 (exclusive)
5050
5151``` js copy
5252function randomNumberGeneratorInRange (rangeStart , rangeEnd ) {
53- return rangeStart + Math .round (Math .random () * (rangeEnd - rangeStart));
53+ return rangeStart + Math .floor (Math .random () * (rangeEnd - rangeStart + 1 ))
5454}
5555
5656randomNumberGeneratorInRange (10 , 50 ); // 12
@@ -68,8 +68,8 @@ Usage of `Math.round` depends on the logic used to accomplish the requirement
6868
6969### 4. Write a program to reverse a string
7070
71- - String can be reversed by iterating it and storing it in reverse order
72- - String can also be reversed by converting it to array, then joining it after reversing
71+ - A string can be reversed by iterating over it and storing it in reverse order
72+ - A string can also be reversed by converting it to an array, then joining it after reversing
7373
7474``` js copy
7575const str = " JavaScript is awesome" ;
0 commit comments