-
-
Notifications
You must be signed in to change notification settings - Fork 116
WEST-MIDLANDS-JAN-ITP|SEGUN FOLAYAN|STRUCTURING AND TESTING DATA|SPRINT1 #428
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
f8c78ec
104698a
109059c
92e370e
0bdab4d
97040bb
a06cf9b
fc48638
bdf8203
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
let count = 0; | ||
|
||
count = count + 1; | ||
count = count + 1; // Further note based on feedback => I can also describe this as 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 three adds 1 to the value of count and stores it as count | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
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? I have added stroke to comment it out. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// trying to create an age variable and then reassign the value by 1 | ||
|
||
const age = 33; | ||
let age = 34; | ||
age = age + 1; | ||
console.log(age); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// 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}`); | ||
// what's the error ? const cityofBirth needs to be declared before it can be used. | ||
const cityOfBirth = "Bolton"; | ||
console.log(`I was born in ${cityOfBirth}`); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
const cardNumber = 4533787178994213; | ||
const last4Digits = cardNumber.slice(-4); | ||
//const last4Digits = cardNumber.slice(-4); | ||
const last4Digits=cardNumber.toString().slice(-4); | ||
console.log(last4Digits); | ||
|
||
// 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? | ||
// Before running the code, make and explain a prediction about why the code won't work- This is because .slice is a string method. | ||
// Then run the code and see what error it gives-It says cardNumber.slice is not a function. | ||
// Consider: Why does it give this error? Is this what I predicted? If not, what's different? Like I mentioned .slice is string method. | ||
// Then try updating the expression last4Digits is assigned to, in order to get the correct value |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
const 12HourClockTime = "20:53"; | ||
const 24hourClockTime = "08:53"; | ||
const 24hourClockTime = "08:53"; // This should be correctly written as "08:53 PM" in the 24 hour format | ||
|
||
// Further information based on review: | ||
// line 1 should be written as const twelveHourClockTime = "20:53", | ||
// line 2 should be written as const twentyFourHourClockTime = "08:53" | ||
// |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const movieLength = 8784; // length of movie in seconds | ||
//const movieLength = 100; | ||
|
||
const remainingSeconds = movieLength % 60; | ||
const totalMinutes = (movieLength - remainingSeconds) / 60; | ||
|
@@ -11,15 +12,21 @@ 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? | ||
// a) How many variable declarations are there in this program? 6 | ||
|
||
// b) How many function calls are there? | ||
// b) How many function calls are there? 1 | ||
|
||
// c) Using documentation, explain what the expression movieLength % 60 represents | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
// % is the module operator, which calculated the remainder of the division of movieLength by 60 | ||
// Further information based on feedback: This expresss represents the seconds left over when all the full minutes of the movie has been subtracted from total time. | ||
|
||
// d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
// d) Interpret line 4, what does the expression assigned to totalMinutes mean? Computes the the difference between movielength and remaining minutes. And divides this by 60. | ||
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. Your description is a literal translation (in English) of Can you describe the value the expression calculates? 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 calculates the number of full completed minutes the movie takes |
||
|
||
// e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
// e) What do you think the variable result represents? Can you think of a better name for this variable? It gives the time of the movie in hours, minutes and seconds | ||
// Further Information based on feedback => variable counld be moviedurationHMS | ||
|
||
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer. It does work for all number inputs. | ||
// f) For example, movieLength of 100 gives 0:-1:-40 and movieLength of 8784 gives 2:26:24 | ||
|
||
//Further information based on feedback: This is a mistake, it should be 0:1:40 |
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.
Operation like
count = count + 1
is very common in programming, and there is a programming term describing such operation.May I suggest feeding the code to ChatGPT and see how else the code can be described? From time to time you may learn some new programming terms.
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.
The operation count = count + 1 is called increment.