From 54a88fbe32cb5d83f912552ed84a14b42227d615 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 2 Mar 2026 03:30:14 +0000 Subject: [PATCH 01/17] added instruction for finding initials and console log to check output --- Sprint-1/1-key-exercises/1-count.js | 3 ++- Sprint-1/1-key-exercises/2-initials.js | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..9bcd3cf8e 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -3,4 +3,5 @@ let count = 0; count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 -// Describe what line 3 is doing, in particular focus on what = is doing +// Line 3 increments the variable by 1 + diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..5b0f3622a 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,10 @@ let lastName = "Johnson"; // Declare a variable called initials that stores the first character of each string. // This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. -let initials = ``; +let initials = `${firstName[0]}${middleName[0]}${lastName[0]}`; + +console.log(initials); + // https://www.google.com/search?q=get+first+character+of+string+mdn From 4c84db9bda356c5c86eabc36a8bd48e8d5ae3c8c Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 2 Mar 2026 03:42:20 +0000 Subject: [PATCH 02/17] added dir and ext variables --- Sprint-1/1-key-exercises/3-paths.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28..89dbccf2e 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -17,7 +17,7 @@ console.log(`The base part of ${filePath} is ${base}`); // Create a variable to store the dir part of the filePath variable // Create a variable to store the ext part of the variable -const dir = ; -const ext = ; +const dir =filePath.slice(0, lastSlashIndex) +const ext =base.slice(base.lastIndexOf(".") + 1) // https://www.google.com/search?q=slice+mdn \ No newline at end of file From f60234be8c28cc444e4fc7f8192e68d42f09a35a Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 2 Mar 2026 03:46:47 +0000 Subject: [PATCH 03/17] added console log and comments explaining the process --- Sprint-1/1-key-exercises/4-random.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..a28eadfdb 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -7,3 +7,13 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // Try breaking down the expression and using documentation to explain what it means // It will help to think about the order in which expressions are evaluated // Try logging the value of num and running the program several times to build an idea of what the program is doing + +console.log(num); + +//num is a random number between 1 and 100 +//Math.floor rounds the decimal number to nearest lower number +// Math.random() generates a random decimal number between 0 and 1 +// when max – min need to add +1 or not all the numbers will be +// included for instance max=5 min=1 5-1=4 but there are +// 5 numbers, 1, 2, 3, 4,5 so need to +1 +//• + minimum → shift the range up to start at the minimum value From e49b1fc9297150d3203a587144f36ceb35151447 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 2 Mar 2026 03:48:53 +0000 Subject: [PATCH 04/17] making the lines into comments --- Sprint-1/2-mandatory-errors/0.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..8c0079d87 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,3 @@ -This is just an instruction for the first activity - but it is just for human consumption -We don't want the computer to run these 2 lines - how can we solve this problem? \ No newline at end of file +//This is just an instruction for the first activity - but it is just for human consumption +//We don't want the computer to run these 2 lines - how can we solve this problem? +//putting two forward slashes at the start of the line makes it a comment, which means the computer will ignore it when running the program \ No newline at end of file From fc3d35e3019d7fe7ea25ac83ed82e0005c7b1261 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 2 Mar 2026 03:51:49 +0000 Subject: [PATCH 05/17] changed const to let and commented why --- Sprint-1/2-mandatory-errors/1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..579d22091 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,5 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; +//const age = 33; needs to be let or the value cannot be reassigned +let age = 33; age = age + 1; From 578f8167c8116b2243e369c4f90f73a926f94a78 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 2 Mar 2026 03:54:36 +0000 Subject: [PATCH 06/17] changed order and commented --- Sprint-1/2-mandatory-errors/2.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..ab9bc2aa9 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,5 +1,9 @@ // Currently trying to print the string "I was born in Bolton" but it isn't working... // what's the error ? -console.log(`I was born in ${cityOfBirth}`); +//console.log(`I was born in ${cityOfBirth}`); +//const cityOfBirth = "Bolton"; +// these are in the wrong order. Cannot access the value of cityOfBirth before it has been declared. Need to declare the variable first and then log it to the console. + const cityOfBirth = "Bolton"; +console.log(`I was born in ${cityOfBirth}`); \ No newline at end of file From cfe1b0cc419be2fafefdcc48c59b489108aa7288 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 2 Mar 2026 04:11:02 +0000 Subject: [PATCH 07/17] changed to function and commented with alternative changes --- Sprint-1/2-mandatory-errors/3.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..0506d8d2f 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -7,3 +7,15 @@ const last4Digits = cardNumber.slice(-4); // Then run the code and see what error it gives. // Consider: Why does it give this error? Is this what I predicted? If not, what's different? // Then try updating the expression last4Digits is assigned to, in order to get the correct value + + +//cardNumber is a number and slice does not work with numbers only strings +// to fix this we can convert the number to a string and then use slice +// to get the last 4 characters of the string, which will be the last 4 digits of the original number +// const last4DigitsString = cardNumber.toString().slice(-4); +// or make it into a function that takes a number as an argument and returns the last 4 digits as a string + +function last4Digits(cardNumber) + return `${cardNumber}`.slice(-4); + +console.log(last4Digits(cardNumber)); From 3b76794bde0cdc315a4d7aaef4144abe8b8b2223 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 2 Mar 2026 04:18:02 +0000 Subject: [PATCH 08/17] explain error --- Sprint-1/2-mandatory-errors/4.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..c4d4d8eb9 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,4 @@ const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +const 24hourClockTime = "08:53"; +// variable names cannot begin with a number +// can change to ClockTime12Hour and ClockTime24Hour or something similar to make it valid \ No newline at end of file From 122b38207904532152d4fc3d46bfb693fa67923b Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 2 Mar 2026 04:58:10 +0000 Subject: [PATCH 09/17] answered the questions --- .../3-mandatory-interpret/1-percentage-change.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..bddc47cc3 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -12,11 +12,25 @@ console.log(`The percentage change is ${percentageChange}`); // Read the code and then answer the questions below // a) How many function calls are there in this file? Write down all the lines where a function call is made +// there are 4 function calls - Replace All is called twice and Number is called twice +// if console.log is considered a function call then there are 5 function calls in total // b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? +// there is a comma missing in line 5 it should be +// priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); +// Replace All requires two arguments which should be separated by a comma, without the comma +// it cannot tell where the first argument ends and the second argument begins // c) Identify all the lines that are variable reassignment statements +// there are 2 variable reassignment statements +// carPrice is reassigned on line 4 - the original value was declared in the let statement on line 1 +// priceAfterOneYear is reassigned on line 5 - the original value was declared in the let statement on line 2 // d) Identify all the lines that are variable declarations +// variable declarations are where the variable is declared for the first time +// This happens in lines 1, 2 with let statements and in lines 7, 8 with const statements // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +// it replaces the commas in the numbers such as 20,000 so calculations can be done +// with commas the numbers are recognised as a string but with spaces they can be recognised as numbers +// calculations cannot be performed on strings so they need to be converted to numbers From 705d9fb0c20336be3d48851a50c71b621c44cee8 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 2 Mar 2026 05:39:25 +0000 Subject: [PATCH 10/17] answered the questions --- Sprint-1/3-mandatory-interpret/2-time-format.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d239558..b89059f69 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -1,4 +1,4 @@ -const movieLength = 8784; // length of movie in seconds +const movieLength = 15560; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -12,14 +12,27 @@ console.log(result); // For the piece of code above, read the code and then answer the following questions // a) How many variable declarations are there in this program? +// there are 6 variable declarations - remainingSeconds, totalMinutes, remainingMinutes, +// totalHours, result and movieLength // b) How many function calls are there? +// there is 1 function call - console.log is called on the last line to print the result to the console // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators +// It is counting the remaining seconds after all the full minutes have been taken out of the movie length. +// For example if the movie length is 125 seconds, then 125 % 60 would give us 5 seconds remaining after taking out the full minutes (2 minutes in this case). // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +// The expression (movieLength - remainingSeconds) / 60 calculates the total number of minutes in the movie length. +// It subtracts the remaining seconds from the total seconds and then divides by 60 to get the total minutes. // e) What do you think the variable result represents? Can you think of a better name for this variable? +// result gives the length of the movie in hours, minutes and seonds +// a better name may be movieLengthFormatted or something similar // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +// Yes, this code will work for all values of movieLength +//%60 gives the remainder and the remainder is always taken away before dividing for minutes and hours +// so it will always give the correct number of hours, minutes and seconds regardless of the length of +// the movie in seconds. \ No newline at end of file From 28d498740017d6dd979870ec512f90e9deb1c2fc Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 2 Mar 2026 06:08:42 +0000 Subject: [PATCH 11/17] answered the questions --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..08a075743 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -11,6 +11,7 @@ const pounds = paddedPenceNumberString.substring( paddedPenceNumberString.length - 2 ); + const pence = paddedPenceNumberString .substring(paddedPenceNumberString.length - 2) .padEnd(2, "0"); @@ -25,3 +26,23 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" + +//2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1): +// removes the last character "p" from the string to get just the number part of the price in pence + +//3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): +// checks if the number is 3 digits and if it is less than 3 digits adds leading zeros to make it 3 digits long +// if it is less than 3 digits long it adds leading zeros ie if 5p it would become 005 + +//4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): +// Ignores the last 2 numbers in the string (these are pence) and defines the remaining numbers as pounds. +// So if the number was 399 that would be £3. If th number was 2050 that would be £20 +// if it was 5p it would be 0 + +//5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): +// takes the last 2 numbers of the string which represent the pence and if it is less than 2 digits adds trailing zeros to make it 2 digits long +// due to step 3 the string should always have at least 3 numbers but this is a safety precaution + +//6. console.log(`£${pounds}.${pence}`): prints the final result in the format of £pounds.pence to the console +// prints the result £pounds.pence so in this case £3.99 it prints the £ sign then the value of pounds +// designated by the $ sign and the value of pence designated by the $sign \ No newline at end of file From f94b1e6dc5a27fe2cb6138186349061d2d55d1fe Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 2 Mar 2026 06:49:28 +0000 Subject: [PATCH 12/17] answered questions --- Sprint-1/4-stretch-explore/chrome.md | 4 ++++ Sprint-1/4-stretch-explore/objects.md | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index e7dd5feaf..ddf975671 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -11,8 +11,12 @@ In the Chrome console, invoke the function `alert` with an input string of `"Hello world!"`; What effect does calling the `alert` function have? +a pop up box appears saying thecharitych.com says this is an alert Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. What effect does calling the `prompt` function have? +a pop up box appears saying thecharitych.com says What is your name + What is the return value of `prompt`? +when I do console.log(answer); it returns the value myName diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56..d5f49fb0a 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -5,12 +5,22 @@ In this activity, we'll explore some additional concepts that you'll encounter i Open the Chrome devtools Console, type in `console.log` and then hit enter What output do you get? +ƒ log() { [native code] } Now enter just `console` in the Console, what output do you get back? +console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …} Try also entering `typeof console` +'object' Answer the following questions: What does `console` store? +console stores functions and allows you to display and inspect information in the browser console. + What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +console.log prints the value of whatever you ask it to print ie console.log(portfolio) would print the value of portfolio whereas console.log("portfolio") would print the actual word portfolio. + +console.assert tests for a condition but only returns a message if the condition is false. For instance it may be used to check the age of a person to restrict access to a site for adults only. + +the full stop is used to separate the object from the method. Console is the object and log and assert are methods \ No newline at end of file From ffee9e4587886f06e07145abeb71a76829ba29ee Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Tue, 3 Mar 2026 09:18:57 +0000 Subject: [PATCH 13/17] added curly brackets --- Sprint-1/1-key-exercises/4-random.js | 2 +- Sprint-1/2-mandatory-errors/3.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index a28eadfdb..3641846e8 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -10,7 +10,7 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; console.log(num); -//num is a random number between 1 and 100 +//num is a random number [1,100] //Math.floor rounds the decimal number to nearest lower number // Math.random() generates a random decimal number between 0 and 1 // when max – min need to add +1 or not all the numbers will be diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index 0506d8d2f..72d21f66d 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -15,7 +15,8 @@ const last4Digits = cardNumber.slice(-4); // const last4DigitsString = cardNumber.toString().slice(-4); // or make it into a function that takes a number as an argument and returns the last 4 digits as a string -function last4Digits(cardNumber) +function last4Digits(cardNumber) { return `${cardNumber}`.slice(-4); +} console.log(last4Digits(cardNumber)); From 90e26259babc7c874243152eec8296892ed9c3db Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Tue, 3 Mar 2026 09:20:00 +0000 Subject: [PATCH 14/17] made variable names lower case first letter --- Sprint-1/2-mandatory-errors/4.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index c4d4d8eb9..597b9b641 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,4 +1,4 @@ const 12HourClockTime = "20:53"; const 24hourClockTime = "08:53"; // variable names cannot begin with a number -// can change to ClockTime12Hour and ClockTime24Hour or something similar to make it valid \ No newline at end of file +// can change to clockTime12Hour and clockTime24Hour or something similar to make it valid \ No newline at end of file From 4a031a09d4f2da7c10105ec7a449bb56b1fe591d Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Tue, 3 Mar 2026 09:51:37 +0000 Subject: [PATCH 15/17] amended responses to prompt --- Sprint-1/4-stretch-explore/chrome.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index ddf975671..73c582918 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -19,4 +19,13 @@ What effect does calling the `prompt` function have? a pop up box appears saying thecharitych.com says What is your name What is the return value of `prompt`? -when I do console.log(answer); it returns the value myName + +Using: +const myName = prompt("What is your name?"); +console.log(myName); + +If I click ok without entering my name the prompt goes off the screen and console.log returns undefined + +If I click cancel without entering my name the promptgoes off the screen and console.log null undefined + +If I put my name Hayriye in and click ok then it goes off the screen and console.log returns Hayriye \ No newline at end of file From b67539e9c8a11fa8117d7e36fa6d85e90d3cbfd4 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Tue, 3 Mar 2026 10:17:28 +0000 Subject: [PATCH 16/17] added more explanation regarding dot operator --- Sprint-1/4-stretch-explore/objects.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index d5f49fb0a..bda75548c 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -23,4 +23,13 @@ console.log prints the value of whatever you ask it to print ie console.log(port console.assert tests for a condition but only returns a message if the condition is false. For instance it may be used to check the age of a person to restrict access to a site for adults only. -the full stop is used to separate the object from the method. Console is the object and log and assert are methods \ No newline at end of file +the full stop is used to separate an object from its method. +In console.log and console.assert console is the object and log and assert are methods. +The full stop is called the 'dot operator' or 'member access operator' +The dot operator accesses a property or method of an object +For example console.log means access the log method from the console object +and console.assert means access the assert method from the console object + + + + From ae3854e200314f6df8f48583788f77cf2762826e Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Tue, 3 Mar 2026 19:01:38 +0000 Subject: [PATCH 17/17] changed lines 13 and 15 to include end numbers --- Sprint-1/1-key-exercises/4-random.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 3641846e8..cac9bd814 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -10,9 +10,9 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; console.log(num); -//num is a random number [1,100] +//num is a random number between 1 and 100 including 1 and 100 [1,100] //Math.floor rounds the decimal number to nearest lower number -// Math.random() generates a random decimal number between 0 and 1 +// Math.random() generates a random decimal number between 0 and 1 including 0 and 1 [0,1] // when max – min need to add +1 or not all the numbers will be // included for instance max=5 min=1 5-1=4 but there are // 5 numbers, 1, 2, 3, 4,5 so need to +1