Skip to content

Commit 445debd

Browse files
committed
applying the feedback i got from mentor
1 parent e412e75 commit 445debd

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
const minimum = 1;
2-
const maximum = 100;
3-
1+
const [min, max] = [1, 100];
42
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
53

64
// In this exercise, you will need to work out what num represents?
75
// Try breaking down the expression and using documentation to explain what it means
86
// It will help to think about the order in which expressions are evaluated
97
// Try logging the value of num and running the program several times to build an idea of what the program is doing
108

11-
/*num represent any value between 1 to 100.
9+
/*num represents a number in [1, 100] and Math.random() returns a number in [0, 1).
1210
Math.floor is a method that rounds a number down to the nearest whole number.
13-
Math.random is a method returning any number that is greater than or equal to 0 and less than 1.
14-
first of all i will try to get a value from 0 to less than 1 from Math.random and multiple it by 100
11+
first of all i will try to get a value [0, 1) from Math.random and multiple it by 100
1512
and apply Math.floor to the result which will give me the integer number and then add the minimum value i.e. 1 */

Sprint-1/2-mandatory-errors/3.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const cardNumber = "4533787178994213";
2-
const last4Digits = cardNumber.slice(-4);
1+
const cardNumber = 4533787178994213;
2+
const last4Digits = cardNumber.toString().slice(-4);
33

44
// The last4Digits variable should store the last 4 digits of cardNumber
55
// However, the code isn't working

Sprint-1/3-mandatory-interpret/2-time-format.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ console.log(result);
2626
//This expression calculates the total full minutes in the movie by removing leftover seconds and converting seconds to minutes.
2727

2828
// e) What do you think the variable result represents? Can you think of a better name for this variable?
29-
//result represent the total movie length using hours,minutes and seconds,the better name can be totalMovieDuration.
29+
//result represent the total movie length using hours,minutes and seconds,the better name can be movieRunTime.
3030

3131
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
3232
/*the code works for different values of movieLength it present the input movieLength by calculating the remainder and subtracting

Sprint-1/3-mandatory-interpret/3-to-pounds.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const penceString = "0p";
1+
const penceString = "340210p";
22

33
const penceStringWithoutTrailingP = penceString.substring(
44
0,
@@ -11,9 +11,9 @@ const pounds = paddedPenceNumberString.substring(
1111
paddedPenceNumberString.length - 2
1212
);
1313

14-
const pence = paddedPenceNumberString.substring(
15-
paddedPenceNumberString.length - 2
16-
);
14+
const pence = paddedPenceNumberString
15+
.substring(paddedPenceNumberString.length - 2)
16+
.padEnd(2, "0");
1717
console.log(${pounds}.${pence}`);
1818

1919
// This program takes a string representing a price in pence

0 commit comments

Comments
 (0)