Skip to content

Commit 4f047d6

Browse files
committed
// so it does not run code
1 parent f18d99c commit 4f047d6

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎Sprint-2/3-mandatory-interpret/3-to-pounds.js‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ console.log(`£${pounds}.${pence}`);
2626

2727
// To begin, we can start with
2828
// 1. const penceString = "399p": initialises a string variable with the value "399p"
29-
const penceString = "399p"; creates a variable. This string represents a price in pence.
30-
We then count the variable penceString using index starting from 0 and ending at 3.
31-
.length tells us how many characters there are in a string which in this case its 4.
32-
Because we know penceString = 4 we have to then subtract 4-1=3.---> we have penceString.length-1 which then becomes 4 - 1 = 3.
33-
we are doing this so we can remove the final character.
34-
penceString.substring(0, 3) will give us "399"
35-
padStart() adds characters to the beginning of a string until it reaches a certain length, we asked for a length of 3.
36-
The final two characters represents pence and we are trying to get poundsright now.Because we have "399" and the last two digits represents pence and the character before that represents pounds.
37-
we are subtracting 2 because when using substringwe remove the part that belongs to pence, 3 | 99
38-
padEnd count at the position of the last two digits and take everything after that so we can get the right value for pence.
39-
here we are making sure that pence has 2 characters- this generally means that if the string does not add to 2 characters, add 0 to the end until its 2 characters Long
40-
console.log displays something in the console as the backticks create a template literal inside it we put our variables.
29+
//const penceString = "399p"; creates a variable. This string represents a price in pence.
30+
//We then count the variable penceString using index starting from 0 and ending at 3.
31+
//.length tells us how many characters there are in a string which in this case its 4.
32+
//Because we know penceString = 4 we have to then subtract 4-1=3.---> we have penceString.length-1 which then becomes 4 - 1 = 3.
33+
//we are doing this so we can remove the final character.
34+
//penceString.substring(0, 3) will give us "399"
35+
//padStart() adds characters to the beginning of a string until it reaches a certain length, we asked for a length of 3.
36+
//The final two characters represents pence and we are trying to get poundsright now.Because we have "399" and the last two digits represents pence and the character before that represents pounds.
37+
//we are subtracting 2 because when using substringwe remove the part that belongs to pence, 3 | 99
38+
//padEnd count at the position of the last two digits and take everything after that so we can get the right value for pence.
39+
//here we are making sure that pence has 2 characters- this generally means that if the string does not add to 2 characters, add 0 to the end until its 2 characters Long
40+
//console.log displays something in the console as the backticks create a template literal inside it we put our variables.

0 commit comments

Comments
 (0)