-
-
Notifications
You must be signed in to change notification settings - Fork 195
Manchester | ITP-May-2025 | Chukwuemeke Ajuebor | Module-Structuring-and-Testing-Data | Sprint-1 #603
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?
Manchester | ITP-May-2025 | Chukwuemeke Ajuebor | Module-Structuring-and-Testing-Data | Sprint-1 #603
Changes from all commits
2416665
979f4d4
0abf0e8
06e4cfb
79812f2
1d8b900
0770499
07feb83
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,2 +1,4 @@ | ||
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? | ||
|
||
//we can solve this by simply using the double forward slash (quote sign) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
// Currently trying to print the string "I was born in Bolton" but it isn't working... | ||
// what's the error ? | ||
// It is a reference error and it is as a result of the variable being accessed before it is created | ||
// The first line shoulfd come before the second line | ||
|
||
console.log(`I was born in ${cityOfBirth}`); | ||
const cityOfBirth = "Bolton"; | ||
console.log(`I was born in ${cityOfBirth}`); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
const cardNumber = 4533787178994213; | ||
const cardNumber = "4533787178994213"; | ||
const last4Digits = cardNumber.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? | ||
// Then try updating the expression last4Digits is assigned to, in order to get the correct value | ||
|
||
// The code won't work because the variable "cardNumber" is not a string. | ||
// Since it is a constant variable, we will have to change directly by putting quote signs around it to make it a string. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
const 12HourClockTime = "20:53"; | ||
const 24hourClockTime = "08:53"; | ||
//const 12HourClockTime = "20:53"; | ||
//const 24hourClockTime = "08:53"; | ||
|
||
// In the above, error will occur as Variable names are not allowed to start with a number. | ||
// This means that we must modify the names slightly. | ||
|
||
const Hour24ClockTime = "20:53"; | ||
const Hour12ClockTime = "08:53"; | ||
|
||
console.log(Hour24ClockTime) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const movieLength = 8784; // length of movie in seconds | ||
const movieLength = 34; // length of movie in seconds | ||
|
||
const remainingSeconds = movieLength % 60; | ||
const totalMinutes = (movieLength - remainingSeconds) / 60; | ||
|
@@ -12,14 +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? | ||
// There are 6 variable declarations | ||
|
||
// b) How many function calls are there? | ||
// There is no function call. | ||
|
||
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 are you using to view the result variable? Are you sure there are 0 function calls? |
||
// c) Using documentation, explain what the expression movieLength % 60 represents | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
// That is the remainder operator and outputs the leftover after division of one operand by the other. | ||
|
||
// d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
//It takes the total movie duration in seconds and removes the remainder that would come about if the | ||
//total seconds were divided by 60: That way, line4 is sure to bring a whole number back. | ||
|
||
// e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
//It represents the movie duration in the format; HH:MM:SS. A good name would be "movieduration" | ||
|
||
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. Do you think that "movieduration" offers a clear enough difference to the earlier "movieLength" variable? |
||
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
// Yes it will as long as the minimum movielength is 1 sec. The divided operand will always be returned if the dividing operand can go into it. | ||
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 think of any cases where the output might not look correct? |
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.
There are 3 lines with function calls on them. How many function calls are there in total?