generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 239
Birmingham | 25-ITP-Sep | Baba Yusuf| Sprint 1 | Module-Structuring-and-Testing Data #737
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
Open
Baba05206
wants to merge
24
commits into
CodeYourFuture:main
Choose a base branch
from
Baba05206:coursework/sprint-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
53bf546
tested node js in VSCode
Baba05206 7f44d44
tested node js in VSCode
Baba05206 51decb7
tested node js in VSCode
Baba05206 cc4ee1c
added Line 3 desc + checked output of expression
Baba05206 a83775d
declared var initials + logged output to console
Baba05206 e262356
created dir & ext variables + logged output to console
Baba05206 5a27b07
logged output of num to console + ran prog severally to generate rand…
Baba05206 e5b59c3
included explanation of the expression
Baba05206 19900cf
updated to correct code error
Baba05206 81e5bf5
updated to correct code error
Baba05206 9584255
updated to correct code error
Baba05206 20639c2
updated to correct code error
Baba05206 71c6802
updated to correct code error
Baba05206 a36e160
completed scheduled tasks
Baba05206 ee63ed9
completed scheduled tasks
Baba05206 be6a3b0
completed scheduled tasks
Baba05206 a6c092d
submitted completed task
Baba05206 4b403bd
submitted completed task
Baba05206 ce151be
submitted completed task
Baba05206 e14a4d8
submitted completed task
Baba05206 f33255c
submitted completed task
Baba05206 c26d1a3
refactor: fix syntax errors and improve function definitions in key e…
Baba05206 496ec07
refactor: remove commented-out code and improve clarity in key error …
Baba05206 c61be3d
refactor: update movieLength value and enhance comments for clarity
Baba05206 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
// trying to create an age variable and then reassign the value by 1 | ||
|
||
const age = 33; | ||
age = age + 1; | ||
let age = 33; //changing const to let allows reassignment. | ||
age = age + 1; //age is now 34 | ||
|
||
console.log(age); //This line was added just to test the expression. Returns 34. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
// Currently trying to print the string "I was born in Bolton" but it isn't working... | ||
// what's the error ? | ||
|
||
// ReferenceError: Cannot access 'cityOfBirth' before initialization | ||
/* | ||
console.log(`I was born in ${cityOfBirth}`); | ||
let cityOfBirth = "Bolton"; | ||
*/ | ||
// The error is because cityOfBirth is declared with const and is being accessed before its declaration. | ||
// Changing const to let to help solve the problem. | ||
// I am also declaring the variable 'cityOfBirth' before before using it. | ||
const cityOfBirth = "Bolton"; | ||
console.log(`I was born in ${cityOfBirth}`); | ||
// Output: I was born in Bolton |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
const cardNumber = 4533787178994213; | ||
const last4Digits = cardNumber.slice(-4); | ||
const last4Digits = cardNumber.toString().slice(-4); // Updated this line to convert number to string first | ||
console.log(last4Digits); // THis is added to see the output of the expression. Should print 4213 | ||
|
||
// 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. | ||
// Before running the code, make and explain a prediction about why the code won't work - I am not very familiar with the slice method on numbers. | ||
/* My prediction is that the slice method is not a function that can be used on numbers, it is a function for strings and arrays. | ||
So I think the error will be something like "slice is not a function" or "cannot read property slice of undefined". | ||
I think this is because numbers do not have properties or methods like strings and arrays do. | ||
To fix this, I will convert the number to a string first, then use the slice method to get the last 4 digits. | ||
I will then convert it back to a number if needed. | ||
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
const 12HourClockTime = "20:53"; | ||
const 24hourClockTime = "08:53"; | ||
const time12HourClock = "08:53"; //1-variable names cannot start with a number // Changed variable name to start with a letter | ||
//2-Swap the values around to match the variable name | ||
const time24hourClockTime = "20:53"; //1-variable names cannot start with a number // Changed variable name to start with a letter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
|
||
// Predict and explain first BEFORE you run any code... | ||
|
||
// this function should square any number but instead we're going to get an error | ||
|
||
// =============> write your prediction of the error here | ||
|
||
/* | ||
function square(3) { | ||
return num * num; | ||
} | ||
|
||
*/ | ||
// =============> write the error message here | ||
|
||
// 1-SyntaxError: Unexpected number. | ||
// =============> explain this error message here | ||
|
||
/* | ||
1-The parameter name '3' is not a valid identifier. Function parameters names must (be valid variable names & not literal values), i.e. start with a letter, underscore (_), or dollar sign ($), and cannot be a number. | ||
2-Also, the function uses 'num' which is not defined anywhere. It should use the parameter name instead. | ||
3-Finally, the function is not called anywhere, so it won't produce any output. | ||
*/ | ||
// Finally, correct the code to fix the problem | ||
|
||
// =============> write your new code here | ||
|
||
|
||
function square(num) { | ||
return num * num; | ||
} | ||
console.log(square(3)); // This line is inserted only to test the function. It returns 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
// Predict and explain first... | ||
|
||
// =============> write your prediction here | ||
|
||
// The function is not returning the output of its calculation. Therefore, when we try to log the result of the function call, it will return 'undefined'. | ||
/* | ||
function multiply(a, b) { | ||
console.log(a * b); | ||
} | ||
|
||
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
||
*/ | ||
// =============> write your explanation here | ||
// 1- The function 'multiply' does not return any value. It only logs the result to the console. | ||
// 2- When 'multiply(10, 32)' is called inside the template literal, it returns 'undefined', so the final output will be "The result of multiplying 10 and 32 is undefined". | ||
|
||
// Finally, correct the code to fix the problem | ||
// =============> write your new code here | ||
function multiply(a, b) { | ||
return a * b; | ||
} | ||
|
||
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
|
||
// The function is not returning the output of its calculation. Therefore, when we try to log the result of the function call, it will return 'undefined'. | ||
/* | ||
function sum(a, b) { | ||
return; | ||
a + b; | ||
} | ||
|
||
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
|
||
*/ | ||
// =============> write your explanation here | ||
// 1- The function 'sum' does not return any value. It only has a return statement without any value, which means it returns 'undefined'. | ||
// 2- When 'sum(10, 32)' is called inside the template literal, it returns 'undefined', so the final output will be "The sum of 10 and 32 is undefined". | ||
|
||
// Finally, correct the code to fix the problem | ||
// =============> write your new code here | ||
function sum(a, b) { | ||
return a + b; | ||
} | ||
|
||
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const http = require("node:http"); | ||
|
||
const hostname = "127.0.0.1"; | ||
const port = 3000; | ||
|
||
const server = http.createServer((req, res) => { | ||
res.statusCode = 200; | ||
res.setHeader("Content-Type", "text/plain"); | ||
res.end("Hello, World!\n"); | ||
}); | ||
|
||
server.listen(port, hostname, () => { | ||
console.log(`Server running at http://${hostname}:${port}/`); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do you have an answer for this last question?