-
-
Notifications
You must be signed in to change notification settings - Fork 117
LONDON_JAN25 | KHALIL ALI | STRUCTURING_AND_TESTING_DATA | SPRINT 1 | WEEK 4 #446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,16 @@ 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 value is :", num) | ||
/* | ||
Math.random():returns a random number between n = [ 0 , 1 [ . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The typical interval notation to represent 0 to 1, including 0 but excluding 1 is, |
||
Math.floor() :returns the previous real number of a decimal number . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This description does not make much sense. |
||
num = Math.floor (n*(100 - 1 + 1) + 1 ; | ||
num = Math.floor (n*100 + 1) | ||
num = Math.floor (100n + 1) | ||
|
||
num range between : [ 1 , 100 ] | ||
num range between : [ minimum , maximum ] | ||
|
||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
/* | ||
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? | ||
We don't want the computer to run these 2 lines - how can we solve this problem? | ||
*/ | ||
|
||
/* | ||
* to add a comment you have two options : | ||
1- // add one line comment | ||
2- /*add multiline comment */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
// Currently trying to print the string "I was born in Bolton" but it isn't working... | ||
// what's the error ? | ||
|
||
const cityOfBirth = "Bolton"; | ||
console.log(`I was born in ${cityOfBirth}`); | ||
const cityOfBirth = "Bolton"; | ||
|
||
|
||
/*code is rendered line by line. | ||
* so you should define the variable cityOfBirth first | ||
* then you can use it | ||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const cardNumber = 4533787178994213; | ||
const cardNumber = "4533787178994213"; | ||
const last4Digits = cardNumber.slice(-4); | ||
Comment on lines
+1
to
2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use an approach that does not involve replacing the original value? |
||
|
||
// The last4Digits variable should store the last 4 digits of cardNumber | ||
|
@@ -7,3 +7,8 @@ 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 | ||
console.log(last4Digits) | ||
|
||
/*slice() is a function takes only string array as an argument. | ||
* thats why we changed cardNumber | ||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
const 12HourClockTime = "20:53"; | ||
const 24hourClockTime = "08:53"; | ||
const HourClockTime24 = "20:53"; | ||
const hourClockTime12 = "08:53"; | ||
|
||
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why start one variable name in lowercase letter and the other one with uppercase letter? |
||
/*variables names can not start with a number. | ||
* | ||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ let carPrice = "10,000"; | |
let priceAfterOneYear = "8,543"; | ||
|
||
carPrice = Number(carPrice.replaceAll(",", "")); | ||
priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); | ||
priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ,"")); | ||
|
||
const priceDifference = carPrice - priceAfterOneYear; | ||
const percentageChange = (priceDifference / carPrice) * 100; | ||
|
@@ -20,3 +20,9 @@ console.log(`The percentage change is ${percentageChange}`); | |
// d) Identify all the lines that are variable declarations | ||
|
||
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
|
||
// a) 3 times . lines (4,5,10) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are more than 3 function calls. Can you identify all of them? |
||
// b) line 5 . syntax error in replaceAll function. add comma | ||
// c) 4 , 5 lines | ||
// d) 1 , 2 , 7 , 8 lines | ||
// e) replace each "," in carPrice with nothing which means : delete each comma | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only described the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you modify your approach for extracting the file extension so that it can work for "name" and the "extension" of any length? For example,
index.html
,3-paths.js
.