Skip to content

Commit 1a219a0

Browse files
committed
updates for sprint 3 restoring .github, Sprint-1 and Sprint -2
1 parent f4f86c7 commit 1a219a0

File tree

14 files changed

+91
-122
lines changed

14 files changed

+91
-122
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: CodeYourFuture
2+
custom: https://codeyourfuture.io/donate

.github/pull_request_template.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!--
2+
3+
You must title your PR like this:
4+
5+
Region | Cohort | FirstName LastName | Sprint | Assignment Title
6+
7+
For example,
8+
9+
London | 25-ITP-May | Carol Owen | Sprint 1 | Alarm Clock
10+
11+
Fill in the template below - remove any sections that don't apply.
12+
13+
Complete the self checklist - replace each empty box in the checklist [ ] with a [x].
14+
15+
Add the label "Needs Review" and you will get review.
16+
17+
Respond to volunteer reviews until the volunteer marks it as "Complete".
18+
19+
-->
20+
21+
## Learners, PR Template
22+
23+
Self checklist
24+
25+
- [ ] I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
26+
- [ ] My changes meet the requirements of the task
27+
- [ ] I have tested my changes
28+
- [ ] My changes follow the [style guide](https://curriculum.codeyourfuture.io/guides/reviewing/style-guide/)
29+
30+
## Changelist
31+
32+
Briefly explain your PR.
33+
34+
## Questions
35+
36+
Ask any questions you have for your reviewer.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Validate PR Metadata
2+
on:
3+
pull_request_target:
4+
types:
5+
- labeled
6+
- unlabeled
7+
- opened
8+
- edited
9+
- reopened
10+
11+
jobs:
12+
validate_pr_metadata:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: CodeYourFuture/actions/validate-pr-metadata@main
17+
with:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-14.3 KB
Binary file not shown.

Sprint-2/1-key-errors/0.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3-
// The code will throw an error because the variable 'str' is being redeclared inside the function 'capitalise'. The error message is likely to be a syntax error.
3+
44
// call the function capitalise with a string input
55
// interpret the error message and figure out why an error is occurring
66

7-
//function capitalise(str) {
8-
// let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9-
//return str;
10-
//}
7+
function capitalise(str) {
8+
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9+
return str;
10+
}
1111

1212
// =============> write your explanation here
13-
// The error is occurring because we are trying to declare a variable 'str' inside the function that has the same name as the parameter 'str'.To fix this problem, create an variable with a new name Newstr . So we would change the line to: Newstr = `${str[0].toUpperCase()}${str.slice(1)}`;
1413
// =============> write your new code here
15-
function capitalise(str) {
16-
let Newstr = `${str[0].toUpperCase()}${str.slice(1)}`;
17-
return Newstr;
18-
}
19-
str="hello world";
20-
console.log(capitalise(str));

Sprint-2/1-key-errors/1.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,19 @@
22

33
// Why will an error occur when this program runs?
44
// =============> write your prediction here
5-
// The error will occur because we are trying to declare a variable with the same name as the parameter of the function. The error message will likely indicate that there is a syntax error or that the variable 'str' has already been declared.
65

76
// Try playing computer with the example to work out what is going on
87

9-
//function convertToPercentage(decimalNumber) {
10-
//const decimalNumber = 0.5;
11-
//const percentage = `${decimalNumber * 100}%`;
8+
function convertToPercentage(decimalNumber) {
9+
const decimalNumber = 0.5;
10+
const percentage = `${decimalNumber * 100}%`;
1211

13-
//return percentage;
14-
// }
12+
return percentage;
13+
}
1514

16-
//console.log(decimalNumber);
15+
console.log(decimalNumber);
1716

1817
// =============> write your explanation here
19-
// The error is occurring because we are trying to declare a variable 'decimalNumber' inside the function that has the same name as the parameter 'decimalNumber'. To fix this problem, we can different variable name for the parameter or the variable inside the function. For example, we could change the line to: const decimalNum = 0.5; and then use 'decimalNum' instead of 'decimalNumber' in the rest of the function.
2018

2119
// Finally, correct the code to fix the problem
2220
// =============> write your new code here
23-
24-
function convertToPercentage(decimalNumber) {
25-
const decimalNum = 0.5;
26-
const percentage = `${decimalNum * 100}%`;
27-
return percentage;
28-
}
29-
console.log(convertToPercentage(0.5));

Sprint-2/1-key-errors/2.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,17 @@
44
// this function should square any number but instead we're going to get an error
55

66
// =============> write your prediction of the error here
7-
// The error will occur because we are trying to declare a function with a parameter that is not a valid variable name. The parameter '3' is not a valid variable name in JavaScript, and this will likely result in a syntax error.
8-
//function square(3) {
9-
// return num * num;
10-
//}
7+
8+
function square(3) {
9+
return num * num;
10+
}
1111

1212
// =============> write the error message here
13-
// SyntaxError: Unexpected number '3'
13+
1414
// =============> explain this error message here
15-
// The error message is indicating that there is a syntax error in the code because we are trying to use a number '3' as a parameter name in the function declaration, which is not allowed in JavaScript. Parameter names must be valid identifiers, which cannot start with a number. To fix this error, we need to change the parameter name to a valid identifier, such as 'num' or 'x'. So we would change the line to: function square(num) { return num * num; }
15+
1616
// Finally, correct the code to fix the problem
1717

1818
// =============> write your new code here
19-
function square(num) {
20-
return num * num;
21-
}
22-
console.log(square(3));
2319

2420

Sprint-2/2-mandatory-debug/0.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
// Predict and explain first...
22

33
// =============> write your prediction here
4-
// The error will occur because the function 'sum' is not returning the result of multiplying 'a' and 'b'. Instead, it is returning 'undefined' due to the function being incomplete. The error message will likely indicate that the result of the sum is 'undefined' when we try to log it to the console.
54

6-
//function multiply(a, b) {
7-
//console.log(a * b);
8-
//}
5+
function multiply(a, b) {
6+
console.log(a * b);
7+
}
98

10-
//console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
9+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1110

1211
// =============> write your explanation here
13-
// The error is occurring because the function 'multiply' is not returning any value. In JavaScript, if a function does not explicitly return a value, it returns 'undefined' by default. To fix this problem, we need to add a return statement to the function that returns the result of multiplying 'a' and 'b'. For example, we could change the line to: return a * b; so that the function will return the correct result when called.
1412

1513
// Finally, correct the code to fix the problem
1614
// =============> write your new code here
17-
function multiply(a, b) {
18-
return a * b;
19-
}
20-
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
21-

Sprint-2/2-mandatory-debug/1.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3-
//The error will occur because the function 'sum' is not returning the result of summing 'a' and 'b'. Instead, it is returning 'undefined' due to the function being incomplete. The error message will likely indicate that the result of the sum is 'undefined' when we try to log it to the console.
4-
//function sum(a, b) {
5-
//return;
6-
//a + b;
7-
//}
83

9-
//console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
10-
11-
// =============> write your explanation here
12-
// The error is occurring because the function 'sum' is not returning any value. In JavaScript, if a function does not explicitly return a value, it returns 'undefined' by default. To fix this problem, we need to add a return statement to the function that returns the result of summing 'a' and 'b'. For example, we could change the line to: return a + b; so that the function will return the correct result when called.
13-
14-
15-
// Finally, correct the code to fix the problem
16-
// =============> write your new code here
174
function sum(a, b) {
18-
return a + b;
5+
return;
6+
a + b;
197
}
208

219
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
10+
11+
// =============> write your explanation here
12+
// Finally, correct the code to fix the problem
13+
// =============> write your new code here

Sprint-2/2-mandatory-debug/2.js

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,23 @@
22

33
// Predict the output of the following code:
44
// =============> Write your prediction here
5-
//the output will be: an error because the function getLastDigit is not defined to take any parameters, but we are trying to pass a number as an argument when we call the function. The error message will likely indicate that getLastDigit is not a function or that it cannot be called with arguments.
65

7-
//const num = 103;
6+
const num = 103;
87

9-
//function getLastDigit() {
10-
//return num.toString().slice(-1);
11-
//}
8+
function getLastDigit() {
9+
return num.toString().slice(-1);
10+
}
1211

13-
//console.log(`The last digit of 42 is ${getLastDigit(42)}`);
14-
//console.log(`The last digit of 105 is ${getLastDigit(105)}`);
15-
//console.log(`The last digit of 806 is ${getLastDigit(806)}`);
12+
console.log(`The last digit of 42 is ${getLastDigit(42)}`);
13+
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
14+
console.log(`The last digit of 806 is ${getLastDigit(806)}`);
1615

1716
// Now run the code and compare the output to your prediction
1817
// =============> write the output here
19-
//it does run but returns the last digit of the number 103 for all three calls to getLastDigit, which is not the expected behavior. The output will be:
20-
// The last digit of 42 is 3
21-
// The last digit of 105 is 3
22-
// The last digit of 806 is 3
23-
2418
// Explain why the output is the way it is
2519
// =============> write your explanation here
26-
// The function getLastDigit is not taking any parameters, so it always returns the last digit of the global variable 'num', which is 103. The function should take a number as a parameter and return the last digit of that number.
27-
2820
// Finally, correct the code to fix the problem
2921
// =============> write your new code here
30-
function getLastDigit(num) {
31-
return num.toString().slice(-1);
32-
}
33-
console.log(`The last digit of 42 is ${getLastDigit(42)}`);
34-
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
35-
console.log(`The last digit of 806 is ${getLastDigit(806)}`);
3622

3723
// This program should tell the user the last digit of each number.
3824
// Explain why getLastDigit is not working properly - correct the problem

0 commit comments

Comments
 (0)