-
-
Notifications
You must be signed in to change notification settings - Fork 221
London|25-ITP-September|Alexandru Pocovnicu|Sprint 1| Coursework #719
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
d543994
a7cc13e
cb1e645
2d115ce
f6b6842
a4b365b
f8be9ec
6631cd9
357720b
f6c81bf
54c1b63
62b453f
9264771
2cb91c3
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 |
---|---|---|
|
@@ -17,7 +17,9 @@ 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(1,lastSlashIndex); | ||
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. In a directory, the first / is important to include when programming. Can you make sure it is captured? |
||
|
||
const extPart=base.lastIndexOf(".") | ||
const ext = base.slice(extPart); | ||
|
||
// https://www.google.com/search?q=slice+mdn |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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? | ||
// 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? | ||
// By commenting out the lines |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
|
||
const age = 33; | ||
age = age + 1; | ||
//the "age" variable has been declared with a const and already assigned a value and it can not | ||
// be reassigned another value because of the "const" | ||
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. What change is needed to fix this? |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
|
||
console.log(`I was born in ${cityOfBirth}`); | ||
const cityOfBirth = "Bolton"; | ||
//a variable needs to be declared before being initialized | ||
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 change the code so that it works? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
const cardNumber = 4533787178994213; | ||
const last4Digits = cardNumber.slice(-4); | ||
// const cardNumber = 4533787178994213; | ||
// const last4Digits = cardNumber.slice(-4); | ||
|
||
|
||
|
||
// The last4Digits variable should store the last 4 digits of cardNumber | ||
// However, the code isn't working | ||
// Before running the code, make and explain a prediction about why the code won't work | ||
// 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 | ||
|
||
|
||
//prediction: it won't work because the value of cardNumber is a number and slice() is a string method | ||
const cardNumber = "4533787178994213"; | ||
const last4Digits = cardNumber.slice(-4); | ||
console.log(last4Digits); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
const 12HourClockTime = "20:53"; | ||
const 24hourClockTime = "08:53"; | ||
// const 12HourClockTime = "20:53"; | ||
// const 24hourClockTime = "08:53"; | ||
|
||
//the name of a variable can not start with a number | ||
|
||
const twelveHourClockTime = "20:53"; | ||
const twenty4hourClockTime = "08:53"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,20 @@ 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? | ||
//6 variable declarations | ||
|
||
// b) How many function calls are there? | ||
//1 function call | ||
|
||
// c) Using documentation, explain what the expression movieLength % 60 represents | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
//% it's the remainder operator and it tells us how many seconds are left out of a whole minute | ||
|
||
// d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
//total time in minutes without the remaining seconds | ||
|
||
// e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
//"Movie length" | ||
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. Is it clear what the difference is between the new "movielength" and original movieLength variables? Could I understand the difference by quickly reading these two variable names? |
||
|
||
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
//it will work with all values as long as they are numbers, | ||
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. consider all the edge cases - are there any inputs that might give strange formatting? |
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.
What is difficult to understand about the MDN docs?